This is a migrated thread and some comments may be shown as answers.

Problem Returning Child Objects

1 Answer 12 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 1
Veteran
Andrew asked on 18 Jun 2014, 12:37 PM
Hey Guys,

I have this query:

​var fetchStrategy = new FetchStrategy();
fetchStrategy.LoadWith<MemberLogin>(x => x.Student);

var emTeamDesigner = new emTeamDesigner();
var query = emTeamDesigner.MemberLogins.Where(x => x.lk_MemberType_pk == 1 && x.Active == true && x.Student.GroupMembers.Any(gm => gm.IveyGroup_pk == courseSectionId)).LoadWith(fetchStrategy);

It returns all Member Objects (MemberLogin) that are of type student (1) and Active that exist in a specific group (GroupMembers)
this looks to be working just fine and I get back the Members I would expect to get back.

The problem is on the MemberLogin object there is a property called Student and this should contain an object called Student but it is always NULL and I am not sure why?

I have tried adding the FetchStategy but that did not help, my model looks fine, and the query had to use student to get its results, but it is not being loaded into the results I get back.

Any ideas?

1 Answer, 1 is accepted

Sort by
0
Viktor Zhivkov
Telerik team
answered on 19 Jun 2014, 12:57 PM
Hi Andrew,

In general Fetch Strategies will instruct Telerik Data Access to load together some queries to improve performance. It should not affect the results, just the moment when they will be loaded.
If the Fetch Strategy that you have posted is not applied, your Student property should be filled using our lazy loading mechanism. So if it is returning NULL, may be you have detached your entity from the context or there is no data in the database.
Can you check if there are any students linked to the MemberLogin records?
Is Students a property that is mapped as association in your data model?
Can you send us your model, some test data and the query that you are executing to reproduce the issue?

Regards,
Viktor Zhivkov
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
LINQ (LINQ specific questions)
Asked by
Andrew
Top achievements
Rank 1
Veteran
Answers by
Viktor Zhivkov
Telerik team
Share this question
or