[ServiceContract]
public interface IService
{
[OperationContract]
string DoSomething(AAA A);
}
[DataContract]
public class BBB
{
public BBB()
{
DicWeiShuIndexSscSyx5 = new Dictionary<string, int>();
DicWeiShuIndexSscSyx5.Add("dfd",2);
DicWeiShuIndexSscSyx5.Add("dgfgfd", 4);
DicWeiShuIndexSscSyx5.Add("dfd5g", 8);
}
[DataMember]
public Dictionary<string, int> DicWeiShuIndexSscSyx5 { get; set; }
public int Gett(int a,int b)
{
return a + b;
}
}
[DataContract]
public class AAA
{
[DataMember]
BBB b;
}
就像上面这种情况,服务的方法参数需要AAA对象,AAA里面又包含BBB对象,更重要的是,服务端和客户端都会访问BBB中的字典和Gett方法,那么,这种情形到底该如何布局呢?上面那样的话,客户端好像无法访问到Gett方法的吧。
------解决思路----------------------
如果bbb的get方法执行后跟服务端没任何关系,那么你可以在客户端的bbb也定义这个方法,但要注意的是,这不是自动添加服务会帮你生成的,你需要手工去改代码,如果get方法需要用到服务端数据库那你这个应该写成服务契约