Page 1 of 1

Entity with include parent object (hirarchical)

Posted: Tue 12 Oct 2010 10:29
by Daniel.Kania
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

Posted: Tue 12 Oct 2010 15:04
by AndreyR
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.

...

Posted: Tue 12 Oct 2010 15:48
by Daniel.Kania
Thank you, it works!

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