public override bool Equals(object obj)
{
//如果类型不同,或者对象为空,一定不相等
if(obj == null || !(obj is GeneralObject))
{
return false;
}
GeneralObject go = obj as GeneralObject;
object thisId = GetPropertyValue("id");
object otherId = go.GetPropertyValue("id");
//如果两个都没有id号或者都没有实体类型,看引用相等否
if ((thisId == null && otherId == null) || (EntityType == null && go.EntityType == null))
{
return base.Equals(obj);
}
//如果其中有一个id或者实体类型为空,一定不相等
if (thisId == null || otherId == null || EntityType == null || go.EntityType == null)
{
return false;
}
//看Id以及实体类型是否相等
bool result = thisId.ToString().Equals(otherId.ToString()) && this.EntityType.Equals(go.EntityType);
return result;
}
#endregion