Пример #1
0
        public virtual bool Equals(BaseEntity entity)
        {
            if (entity == null)
                return false;

            if (ReferenceEquals(this, entity))
                return true;

            if (!IsTransient(this) && !IsTransient(entity) && Equals(Id, entity.Id))
            {
                var thisType = this.GetType();
                var otherType = entity.GetType();
                return thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType);
            }
            return false;
        }
Пример #2
0
 public static bool IsTransient(BaseEntity entity)
 {
     return entity != null && Equals(entity.Id, default(int));
 }