wcf 客户端代理生成的类中缺少数据成员顺序
已将表从 sql 数据库映射到 Employee dbml 文件中的 linq。
[global::System.Runtime.Serialization.DataContractAttribute()]
public partial class tbEmployee
{
private int _Employeeid;
private string _EmployeeName;
public tbEmployee()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Employeeid", DbType = "Int NOT NULL")]
[global::System.Runtime.Serialization.DataMemberAttribute(Order = 0)]
public int EmployeeID
{
get
{
return this._PeriodContextRefId;
}
set
{
if ((this._Employeeid != value))
{
this._Employeeid = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_EmployeeName", DbType = "NVarChar(2) NOT NULL", CanBeNull = false)]
[global::System.Runtime.Serialization.DataMemberAttribute(Order = 1)]
public string EmployeeName
{
get
{
return this._EmployeeName;
}
set
{
if ((this._EmployeeName != value))
{
this._EmployeeName = value;
}
}
}
}
在服务中,当我在客户端中添加服务引用时,我只是返回类型的对象,
List<tbEmployee>
跳过日期会员订单信息。
由于我使用 protobuf-net 进行序列化/反序列化,因此出现了问题 在我的客户端反序列化时。
Have mapped table from sql database to linq in Employee dbml file.
[global::System.Runtime.Serialization.DataContractAttribute()]
public partial class tbEmployee
{
private int _Employeeid;
private string _EmployeeName;
public tbEmployee()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Employeeid", DbType = "Int NOT NULL")]
[global::System.Runtime.Serialization.DataMemberAttribute(Order = 0)]
public int EmployeeID
{
get
{
return this._PeriodContextRefId;
}
set
{
if ((this._Employeeid != value))
{
this._Employeeid = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_EmployeeName", DbType = "NVarChar(2) NOT NULL", CanBeNull = false)]
[global::System.Runtime.Serialization.DataMemberAttribute(Order = 1)]
public string EmployeeName
{
get
{
return this._EmployeeName;
}
set
{
if ((this._EmployeeName != value))
{
this._EmployeeName = value;
}
}
}
}
and in Service i am just returning the object of type
List<tbEmployee>
when i add the service reference in my client the date member order information is skipping.
as i am using the protobuf-net for serialization/deserialization it is giving the problem
while deserializing at my client side.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这很麻烦。有 2 个选项可以解决此问题;第一个(也是最简单的)是使用 WCF 的能力在客户端和服务器之间共享契约程序集。如果您可以共享 DTO 层,那么事情就会变得简单。
第二个是在客户端添加额外的标记以提供线索。您可以通过
partial
类来完成此操作,例如在单独的代码文件中(不要编辑生成的文件):更明确的替代方案是:
Yes, that is a nuisance. There are 2 options for fixing this; the first (and easiest) is to use WCF's ability to share a contract assembly between client and server. If you can share the DTO layer, that'll keep things simple.
The second is to add additional markers at the client to give it a clue. You can do this via a
partial
class, for example in a separate code file (don't edit the generated file):a more explicit alternative is: