可选地在WCF中隐藏DataContract的属性

可选地在WCF中隐藏DataContract的属性,wcf,web-services,Wcf,Web Services,我有一个名为Customer的datacontract,有两个OperationContract,比如CreateCustomer()和UpdateCustomer(),它们将Customer作为数据契约 现在,我需要在UpdateCustomer()中隐藏Customer datacontract的一些属性。例如,在客户数据契约中有一个名为SSN的属性。此属性应在CreateCustomer()中可见,并且不应在UpdateCustomer()中用于更新。你知道怎么做吗 我们是否需要两个Ope

我有一个名为Customer的datacontract,有两个OperationContract,比如CreateCustomer()和UpdateCustomer(),它们将Customer作为数据契约

现在,我需要在UpdateCustomer()中隐藏Customer datacontract的一些属性。例如,在客户数据契约中有一个名为SSN的属性。此属性应在CreateCustomer()中可见,并且不应在UpdateCustomer()中用于更新。你知道怎么做吗

我们是否需要两个OperationContract都有单独的数据协定对象

提前谢谢!
Bala

您需要两个独立的类,一个用于只包含调用应看到的属性的
UpdateCustomer
调用,另一个用于
CreateCustomer
调用(显然,这可以从上一个类继承):

然后你的电话需要参加这些课程:

[ServiceContract]
public interface IMyService
{
   [OperationContract]
   public int CreateCustomer(CreateCustomerData customer);    

   [OperationContract]
   public int UpdateCustomer(UpdateCustomerData customer);    
}

在那里有这样的房产有什么问题?
[ServiceContract]
public interface IMyService
{
   [OperationContract]
   public int CreateCustomer(CreateCustomerData customer);    

   [OperationContract]
   public int UpdateCustomer(UpdateCustomerData customer);    
}