Nhibernate3.0cookbook學習筆記一個基類實體類-創(chuàng)新互聯(lián)

公司專注于為企業(yè)提供網(wǎng)站設計制作、成都網(wǎng)站建設、微信公眾號開發(fā)、商城網(wǎng)站定制開發(fā),微信小程序,軟件定制設計等一站式互聯(lián)網(wǎng)企業(yè)服務。憑借多年豐富的經(jīng)驗,我們會仔細了解各客戶的需求而做出多方面的分析、設計、整合,為客戶設計出具風格及創(chuàng)意性的商業(yè)解決方案,創(chuàng)新互聯(lián)更提供一系列網(wǎng)站制作和網(wǎng)站推廣的服務。 src="/upload/otherpic7/copycode.gif">
using System;

namespace Eg.Core
{
public abstract class Entity<TId>
    {

public virtual TId Id { get; protected set; }
protected virtual int Version { get; 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();
        }

    }

public abstract class Entity : Entity<Guid>
    {

    }

}

文章題目:Nhibernate3.0cookbook學習筆記一個基類實體類-創(chuàng)新互聯(lián)
URL分享:http://muchs.cn/article20/ijhco.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作搜索引擎優(yōu)化、軟件開發(fā)、App設計網(wǎng)站導航、微信公眾號

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網(wǎng)站建設