wcf 客户端代理生成的类中缺少数据成员订单 [英] Data Member Order is missing from wcf client proxy generated class

查看:37
本文介绍了wcf 客户端代理生成的类中缺少数据成员订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已将 sql 数据库中的表映射到 Employee dbml 文件中的 linq.

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;
            }
        }
    }

}

在 Service 中,我只是返回类型为

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.

当我使用 protobuf-net 进行序列化/反序列化时,它出现了问题在我的客户端反序列化时.

as i am using the protobuf-net for serialization/deserialization it is giving the problem while deserializing at my client side.

推荐答案

是的,这很麻烦.有 2 个选项可以解决这个问题;第一个(也是最简单的)是使用 WCF 在客户端和服务器之间共享合约程序集的能力.如果您可以共享 DTO 层,那将使事情变得简单.

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.

第二种是在客户端添加额外的标记以提供线索.您可以通过 partial 类来完成此操作,例如在 separate 代码文件中(不要编辑生成的文件):

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):

namespace YourNamespace {
    [ProtoContract(DataMemberOffset = 1)] /* shift all DataMember orders */
    public partial class tbEmployee {}
}

更明确的替代方法是:

namespace YourNamespace {
    [ProtoPartialMember(1, "EmployeeID")]
    [ProtoPartialMember(2, "EmployeeName")]
    public partial class tbEmployee {}
}

这篇关于wcf 客户端代理生成的类中缺少数据成员订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆