Problem Returning Child Objects

Thread is closed for posting
2 posts, 0 answers
  1. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 18 Jun 2014 Link to this post

    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?

  2. Viktor Zhivkov
    Viktor Zhivkov avatar
    324 posts

    Posted 19 Jun 2014 Link to this post

    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?

    Viktor Zhivkov
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Back to Top