实体类数值重置为ZERO(表示层到服务层) [英] Entity class numeral values reset to ZERO (presentation layer to service layer)

查看:88
本文介绍了实体类数值重置为ZERO(表示层到服务层)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





将实体类对象从表示层转移到服务层时,所有数值都重置为零。

< pre lang =c#> // 实体类库
类实体
{
public int value {获取; set ;}
}



  //   default.aspx.cs  
使用( service1.Execute exe = new service1.Execute())
{
service1.Entity ent = service1.Entity();
ent。 value = 10 ;
exe.Run(ent);
}



  //  服务层 - 我在定义合同时使用界面以便于理解我在同一个类中使用 
[ServiceContract]
class 执行
{
[OperationContract]
public void 运行(实体e)
{
int value = e。; // 我得到零,但我设置为10
}
}



我该如何解决?



谢谢,

问候,
--SJ

解决方案

您必须使用DataContractAttribute和DataMemberAttribute 喜欢这个 [ ^ ]

Hi,

While transferring entity class object from presentation layer to service layer all the numeral values are reset to ZERO.

//Entity Class Library
Class Entity
{
public int value{get; set;}
}


// default.aspx.cs
using(service1.Execute exe = new service1.Execute())
{
service1.Entity ent = new service1.Entity();
ent.value = 10;
exe.Run(ent) ;
}


//service layer - I use interface while defining contracts for easy understanding i used in a same class
[ServiceContract]
class Execute 
{
[OperationContract]
public void Run(Entity e)
{
int value = e.value; // i get zero but i set into 10
}
}


How can i fix it?

Thanks,
Regards,
--SJ

解决方案

You have to use DataContractAttribute and DataMemberAttribute like this[^]


这篇关于实体类数值重置为ZERO(表示层到服务层)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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