3

I have got multiple views with exactly same records structure but different filtering logic. I'd like to be able to query any of them with Entity Framework and it would seem much more natural if they would be returning values of same type instead of using a different type (with exactly same members) for every view. How to achieve this?

I use visual model designer with database-first approach.

UPDATE:

For example: we can have Vehicles table,

create view [GreenVehicles] as select * from [Vehicles] where [Color]='Green';

and

create view [GreenVans] as select * from [GreenVehicles] where [Type]='Van';

The task is to make it so that we would be able to query GreenVans as a collection of GreenVehicles.

4

1 回答 1

0

[更新/ 3]

我完全删除了我原来的例子,因为它与澄清无关。您正在寻找的是返回 IQueryable 对象并在对其执行之前向其添加过滤器。这(在我的理解中)将导致所有工作仍然在服务器端完成,可以在这里找到一个很好的讨论:

http://codethinked.com/keep-your-iqueryable-in-check

欢迎指正!

于 2012-12-18T15:56:38.680 回答