Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate Entity code conversion from #C to VB.Net
    primarykey
    data
    text
    <p>Hello and thanks for your help in advance.</p> <p>I am starting on the NHibernate world and i am experimenting with the NHibernate CookBook recipes, i am trying to set a base entity class for my entities and this is the C# code for this. I would like to know whats the VB.NET version so i can implement it in my sample project.</p> <p>This is the C# code: </p> <pre><code>public abstract class Entity&lt;TId&gt; { public virtual TId Id { get; protected set; } public override bool Equals(object obj) { return Equals(obj as Entity&lt;TId&gt;); } private static bool IsTransient(Entity&lt;TId&gt; obj) { return obj != null &amp;&amp; Equals(obj.Id, default(TId)); } private Type GetUnproxiedType() { return GetType(); } public virtual bool Equals(Entity&lt;TId&gt; other) { if (other == null) return false; if (ReferenceEquals(this, other)) return true; if (!IsTransient(this) &amp;&amp; !IsTransient(other) &amp;&amp; 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(); } } </code></pre> <p>I tried using an online converter but puts a Nothing reference in place of default(TId) that doesn't seem right to me that's why I request for help:</p> <pre><code> Private Shared Function IsTransient(obj As Entity(Of TId)) As Boolean Return obj IsNot Nothing AndAlso Equals(obj.Id, Nothing) End Function </code></pre> <p>I Would appreciate the insight you may give me on the subject.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload