Entity with include parent object (hirarchical)

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Daniel.Kania
Posts: 10
Joined: Wed 10 Mar 2010 13:20

Entity with include parent object (hirarchical)

Post by Daniel.Kania » Tue 12 Oct 2010 10:29

Hello,
i have an entity named "RWork" with following structure:

ID NUMERIC
NAME VARCHAR2
Parent RWork

underlying Database table
--------------------------------
1 Grandfather NULL
2 Father 1
3 Fathers Sister 1
4 Child 3

And now, when i try:

from f in model.RWork
where f.RWork.ID.Equals(4)
select f

i get an Object of RWork (4, "Child", NULL) --> without Parent-object

what i must do, that i get an object of type RWork (4, "Child", RWork)

thanks, Daniel

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 12 Oct 2010 15:04

Try the following code:

Code: Select all

from f in model.RWork.Include("Parent")
where f.RWork.ID.Equals(4) 
select f
In case it doesn't help, please send us (support * devart * com, subject "EF Lazy Loading") a small test project illustrating your scenario.

Daniel.Kania
Posts: 10
Joined: Wed 10 Mar 2010 13:20

...

Post by Daniel.Kania » Tue 12 Oct 2010 15:48

Thank you, it works!

You rescue my life, we are so in schedule pressure :(

Post Reply