开发者

Entity Framework Model with inheritance and RIA Services

开发者 https://www.devze.com 2022-12-24 14:16 出处:网络
We have an entity framework 开发者_StackOverflow中文版model with has some inheritance in it. The following example is not the actuall model, but just to make my point...

We have an entity framework 开发者_StackOverflow中文版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:

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..

0

精彩评论

暂无评论...
验证码 换一张
取 消