New Posts New Posts RSS Feed: Filtered Includes
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Filtered Includes

 Post Reply Post Reply
Author
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Topic: Filtered Includes
    Posted: 10-Apr-2012 at 10:49am
Hi Paul,
 
Sorry for the delay.
I moved your last question to the Cocktail forum.
 
Silvio.
Back to Top
paul View Drop Down
Newbie
Newbie


Joined: 16-Sep-2010
Posts: 19
Post Options Post Options   Quote paul Quote  Post ReplyReply Direct Link To This Post Posted: 09-Apr-2012 at 6:23pm
Any input from anyone? Should I cross-post to the Cocktail forum. I didn't want it to get lost after the holiday weekend. Thanks...
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 06-Apr-2012 at 8:25am
Hi Paul,
 
Unfortunatelly, you won't be able to filter entities retrieved via Include.
However, a workaroud would be using select:
 
var employees = Manager.Employees.Where(e => e.EmployeeId == employeeId)
                                      .Include(e => e.Person)
                                      .Include(e => e.Person.Address)
                                      .Include(e => e.Person.Address.Region)
                                      .Select(e => new { Employee = e,
                                                                    RegionLocalizeds = e.Person.Address.Region.RegionLocalizeds.Where(rl => rl.LanguageTypeId == CurrentLanguageTypeId))
                                      .ToList()
                                      .Select(emp => emp.Employee;
 
 
There is a forum post at http://www.ideablade.com/forum/forum_posts.asp?TID=2097&PID=8208#8208 that address the same issue.
 
Regards,
   Silvio.
 
Back to Top
paul View Drop Down
Newbie
Newbie


Joined: 16-Sep-2010
Posts: 19
Post Options Post Options   Quote paul Quote  Post ReplyReply Direct Link To This Post Posted: 05-Apr-2012 at 8:26pm
I know it isn't possible with EF right now but I was curious what other people have done. This is what my ideal code looks like but since EF doesn't support filtered includes it won't work.

IEntityQuery<Model.Employee> query = Manager
    .Employees
    .Where(e => e.EmployeeId == employeeId)
    .Include(e => e.Person)
    .Include(e => e.Person.Address)
    .Include(e => e.Person.Address.Region)
    .Include(e => e.Person.Address.Region.RegionLocalizeds.Where(rl => rl.LanguageTypeId == CurrentLanguageTypeId));


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down