WCF RIA服务主数据中的DTO [英] DTOs in WCF RIA Services Master-Detail

查看:227
本文介绍了WCF RIA服务主数据中的DTO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须做一个Master-Detail方案,在主人中我可以显示许多类型的项目,它们都实现 IDto

 界面IDto 
{
int Id {get;组; }
string标题{get;组; }
EntityType {get;组;
}

枚举EntityType
{
联系人,
人,
公司,
客户
员工,
供应商
工作
}

注意:我正在使用实体框架EDM(生成 ObjectContext EntityObject s)。



类层次结构是联系人 Person 公司 Person 的子类员工 公司供应商的基类。 客户有一个属性联系人可以是联系人或$ Person ,并列出 Job





现在在主列表,我想从 DomainService (它是一个 LinqToEntitiesDomainService< ObjectContext> 加载一组DTO,而I只需要选择 IDto 合同中的指定字段,然后在选择时,在整个细节区域中加载整个实体及其所有字段/相关数据等。 / p>

更新:我想到了另一个想法。

创建一个数据库视图(SQL2008),返回3行上述 IDto 合同,枚举将作为int或tinyint存储(然后将枚举更改为字节),那么在edm中我可以创建一个每层次的表对于存储在列表中的每个EntityType,并且ret将它从 DomainService 中。



BTW,所有枚举值都将用于查询,实际上,没有实体将返回联系为其 EntityType 属性,因为联系人是抽象的,可以是 Person 公司,但我仍然希望有一个查询选项



更新2

客户还希望,列表中的每个项目也所有的工作。

根据上面描述的层次结构,对于客户 - 选择所有工作;对于联系人 Person - 选择其客户 s Job s(如果它的一个客户)。 供应商员工不是要注册 Job s。



我认为唯一可以做到这一点是数据库视图。

我错了吗?有什么后果?我正在使用SL5与RIA。



观看方式好吗?或者我应该使用客户端POCO处理客户端中的所有查询?因为这个值真的只能用于检索联系人姓名及其工作。进一步的细节和操作将在 Entity 实体的其他视图中完成。



那么你有什么专家认为?我已经找到这个帖子非常有用,实际上让我做一个设计。


  1. 数据库视图不一定是正确的方法

  2. 将通过POCO DTO从域服务返回部分实体。


I have to make a Master-Detail scenario where in the master I can show many types of items, that they all implement IDto:

interface IDto
{
  int Id { get; set; }
  string Title { get; set; }
  EntityType { get; set;
}

enum EntityType
{
  Contact,
  Person,
  Company,
  Customer
  Employee,
  Vendor,
  Job  
}

Note: I am using Entity Framework EDM (generated ObjectContext and EntityObjects).

The class hierarchy is that Contact is the subclass for Person and Company, Person is the baseclass of Employee, Company is the baseclass of Vendor. Customer has a property Contact that can be either a Contact or a Person, and has a list of Job.

Now in the master list, I want to load a collection of DTOs from the DomainService (it's a LinqToEntitiesDomainService<ObjectContext>, and I want only the specified fields in the IDto contract to be selected, then, when selected, load the entire entity with all its fields/related data etc. in the details area.

Update: I thought about another idea.
Create a database-view (SQL2008) that returns the 3 rows of the above IDto contract where the enum will be stored as int or tinyint (will then change the enum to byte), then in the edm I can make a table-per-hierarchy for each EntityType stored in the list, and return it from the DomainService.

BTW, all the enum values will be used for the query, in fact, no entity will return Contact for its EntityType property, because Contact is abstract and can be either a Person or a Company, but I still want to have an option to query both of them.

Update 2
The customer also wants, for each one of the items in the list, also all its jobs.
Based on the hierarchy I described above, for a Customer - select all its jobs; for a Contact or a Person - select its Customer's Jobs (if its a Customer). Vendor or Employees are not meant to be register with Jobs.

I think the only way I can do this is with database-views.
Am I wrong? What are the consequences? I am using SL5 with RIA.

Is the Views way good? Or I should handle all the queries in the client using a client POCO? because really this value are only used to retrieve the contact name and its jobs. further details and manipulation will be done in other views on the Entity entities them selves.

So what do you experts think?

解决方案

I've found this post very useful, and it actually let me to a desicion.

  1. Database views is not necessarily the right approach
  2. Will return the partial entities thru POCO DTOs from the domain service.

这篇关于WCF RIA服务主数据中的DTO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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