我们正在强制执行所有域对象来实现 GetHashCode。
namespace Core
{
[Serializable]
public abstract class DomainObject
{
public abstract override int GetHashCode();
}
}
namespace Entity.Domain
{
[Serializable]
[DataContract]
public partial class IdCard : DomainObject
{
private System.Int32 _effDte;
[DataMember]
public virtual System.Int32 EffDte
{
get { return _effDte; }
set { _effDte = value; }
}
public override int GetHashCode()
{
return EffDte.GetHashCode();
}
}
}
当我们通过 WCF 公开这些域对象时,以下生成的服务需要更新后修改才能编译。
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace IdCardManagerServiceReference {
using System.Runtime.Serialization;
using System;
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="IdCard", Namespace="http://schemas.datacontract.org/2004/07/Entity.Domain")]
[System.SerializableAttribute()]
public partial class IdCard : Core.DomainObject, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
[System.NonSerializedAttribute()]
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private int EffDteField;
[global::System.ComponentModel.BrowsableAttribute(false)]
public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
get {
return this.extensionDataField;
}
set {
this.extensionDataField = value;
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public int EffDte {
get {
return this.EffDteField;
}
set {
if ((this.EffDteField.Equals(value) != true)) {
this.EffDteField = value;
this.RaisePropertyChanged("EffDte");
}
}
}
}
关于如何保持对 GetHashCode 的要求,但删除客户端上任何代码的要求(作为更新或作为部分类)的任何想法?