안녕하세요, 미리 도움을 주셔서 감사합니다.NHibernate #C에서 VB.Net로 엔티티 코드 변환
나는 NHibernate 세계에서 시작하고 NHibernate CookBook 요리법으로 실험하고있다. 내 엔티티의 기본 엔티티 클래스를 설정하려고하는데,이 것은 C# 코드이다. VB.NET 버전이 무엇인지 알고 싶습니다. 그래서 샘플 프로젝트에서 구현할 수 있습니다.
이
는 C# 코드입니다 :public abstract class Entity<TId>
{
public virtual TId Id { get; protected set; }
public override bool Equals(object obj)
{
return Equals(obj as Entity<TId>);
}
private static bool IsTransient(Entity<TId> obj)
{
return obj != null &&
Equals(obj.Id, default(TId));
}
private Type GetUnproxiedType()
{
return GetType();
}
public virtual bool Equals(Entity<TId> other)
{
if (other == null)
return false;
if (ReferenceEquals(this, other))
return true;
if (!IsTransient(this) && !IsTransient(other) && Equals(Id, other.Id))
{
var otherType = other.GetUnproxiedType();
var thisType = GetUnproxiedType();
return thisType.IsAssignableFrom(otherType) ||
otherType.IsAssignableFrom(thisType);
}
return false;
}
public override int GetHashCode()
{
if (Equals(Id, default(TId)))
return base.GetHashCode();
return Id.GetHashCode();
}
}
내가 온라인 변환기를 사용하려하지만 도움을 요청할 그 이유는 나에게 잘 보이지 않는다 기본 (TID) 대신에 아무것도 기준을두고 :
Private Shared Function IsTransient(obj As Entity(Of TId)) As Boolean
Return obj IsNot Nothing AndAlso Equals(obj.Id, Nothing)
End Function
감사의 말을 전하여 주시면 감사하겠습니다.
'default (Object) == null'이므로'Nothing'은'default'와 동의어입니다. – KeithS
입력에 대해 Konrad에게 감사드립니다. 그러면 변환이 작동합니다. 나는 그것을 시도 할 것이다. – CoderRoller