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()
开发者_StackOverflow {
}
[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.
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):
namespace YourNamespace {
[ProtoContract(DataMemberOffset = 1)] /* shift all DataMember orders */
public partial class tbEmployee {}
}
a more explicit alternative is:
namespace YourNamespace {
[ProtoPartialMember(1, "EmployeeID")]
[ProtoPartialMember(2, "EmployeeName")]
public partial class tbEmployee {}
}
精彩评论