RIA and DTO
来源:互联网 发布:敏感性分析软件 编辑:程序博客网 时间:2024/05/19 17:59
RIA and DTO
At the moment (RC bits) WCF RIA doesn’t support custom DTO as parameters for domain service operations. If you define
public class MyCustomDTO
{
[DataMember]
public int MyPayload { get; set; }
[DataMember]
public string MyOtherPayload { get; set; }
}
You won't be able to do this
public void MyOperation(MyCustomDTO data)
Compiler will greet you with this encouraging message:
Operation named 'MyOperation' does not conform to the required signature. Parameter types must be an entity type or one of the predefined serializable types.
Well, don’t be scared, there is workaround (as usual) to make our custom DTO “RIA friendly” (or Entity type in RIA terms).
You need to do 2 simple but not obvious things
1. Make your class identifiable by providing RIA with identity property(ies)
{
[Key]
public int MyDummyKey { get; set; }
public int MyPayload { get; set; }
public string MyOtherPayload { get; set; }
}
Note that we don’t need WCF data contract attributes anymore – RIA code generator takes care of it
2. Expose our “entity” via domain service dummy Query
public IQueryable<MyCustomDTO> GetMyCustomDTODummy() { return null; }
Now you can successfully compile your project and use your custom operation with custom DTO client side
var data = new MyCustomDTO
{
MyPayload = 13,
MyOtherPayload = "Test"
};
ctx.MyOperation(data);
but what about more complex DTOs with sub lists (data graphs)? well, just wait for the next post ;)
- RIA and DTO
- NHibernate SetResultTransformer and DTO
- RIA Services and relational data
- DTO
- DTO
- dto
- DTO
- DTO
- DTO
- dto
- DTO
- DTO
- DTO
- DTO
- ZJava Framework- RIA and Java/Swing framework
- RIA
- RIA
- RIA
- asp.net “从客户端检测到有潜在危险的Request.Form值” 处理办法
- Oracle 常用查询
- Oracle 学习 Day3 - Oracle 文件
- Java中远程调试web应用程序
- 电驴代码编译我最棒(转)
- RIA and DTO
- C#数据库操作(阅读器、数据库绑定、修改、统计、分页)(转)
- C++虚函数表解析
- Jquery 网页右侧快速回复表单,无刷新提交
- 开发板摄像头图像采集调试!!
- 新手求助
- 一些关于C语言的总结
- [linker error] undefined reference to vtable for **
- C#泛型集合Dictionary