I have a simple DB that has Sites, and each Site has a bunch of Posts.
I'm trying to get all the "Public" Posts of a certain Site (I have a variable called site that is already an instance brought by EF)
The first obvious thing is:
var posts = from post in site.Posts
where post.Public == true
orderby post.PublicationTime descending
select post;
This brings me what I want, but looking into SQL Server Profiler, the WHERE only is filtering the Public field, not the Site. In fact, running in SQL Server the query that Profiler captures indeed brings back all the posts from all the sites (and this is obviously being filtered in the ASP.Net side later).
Then I tried:
var posts = from post in db.Posts
where post.Site == site && post.Public == true
orderby post.PublicationTime descending
select post;
Same result.
Am I doing something fundamentally stupid here?
Does Entity Framework ALWAYS filter in the client-side?
Thanks!
Daniel