简体   繁体   English

具有继承和RIA服务的实体框架模型

[英]Entity Framework Model with inheritance and RIA Services

We have an entity framework model with has some inheritance in it. 我们有一个具有一些继承性的实体框架模型。

The following example is not the actuall model, but just to make my point... 以下示例不是实际模型,而是为了说明我的观点。

Let's say 比方说

Base class: Person Child classes: Employee, Customer 基本类别:人员子类别:雇员,客户

The database has been generated, the DomainService has been created and we can get to the data: 数据库已生成,DomainService已创建,我们可以获取数据:

lstCustomers.ItemsSource = context.Persons;
EntityQuery<Person> query = context.GetPeopleQuery().Take(4);
context.Load(query);

But how can I modify the query to only return Customers ? 但是,如何修改查询以仅返回客户?

Have you already tried the following: 您是否已经尝试过以下方法:

context.GetPeopleQuery().OfType<Customer>().Take(4)

I can imagine this doesn't have the required effect though, because the OfType is probably evaluated client-side.. 我可以想象这没有达到要求的效果,因为OfType可能是在客户端评估的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RIA服务:实体框架参考实体 - RIA Services: Entity Framework Reference Entities WCF RIA服务+实体框架4无法连接到数据库 - WCF RIA Services + Entity Framework 4 cannot connect to database 实体框架数据库优先-模型中的继承问题 - Entity Framework DB First - Problems with inheritance in the model 实体框架tpc继承模型创建 - Entity Framework tpc inheritance model creating 实体框架-使用类继承创建模型 - Entity Framework - Model creation using class inheritance 为了使用ria服务,是否应该从模型中删除所有继承? - Should I remove all inheritance from my model in order to work with ria services? 实体框架和RIA服务-无法在客户端的共享类中访问受保护的属性 - Entity Framework & RIA Services - cant access protected property in shared class on client 当子记录不存在时,为什么Entity Framework(带有RIA Services)不包括父记录? - Why is Entity Framework (with RIA Services) excluding parent records when child records don't exist? Silvelight&RIA Services&Entity Framework存在局部类和复杂类型的问题 - Silvelight&RIA Services&Entity Framework problems with partial classes and complex types there 需要帮助调试:无法通过RIA服务,实体框架,MySQL将数据获取到Silverlight应用程序 - Need help debugging: Having trouble getting data to Silverlight App through RIA Services, Entity Framework, MySQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM