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

FetchStrategy does not return related objects

1 Answer 41 Views
Web Services
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Art Kedzierski
Top achievements
Rank 2
Art Kedzierski asked on 18 Jun 2013, 02:36 PM
I have a Silverlight project utilizing ORM. in my Web project I have created a method to fetch a custom class and its related data.

public IQueryable<Web.Appointment> GetAppointmentsByResource(int rscID)
{
    FetchStrategy fetch = new FetchStrategy();
    fetch.LoadWith<Web.Appointment>(f => f.Appt2Rescs);
    fetch.LoadWith<Web.Appointment>(f => f.Attendees);
    this.DataContext.FetchStrategy = fetch;
 
    return this.DataContext.Appointments
                .Where(w => w.Appt2Rescs.Any(r => r.ResourceFK == rscID));
}

I am not seeing the related ILists reflected in the Silverlight project when I implement the method:

LoadOperation<Web.Appointment> loadAppts = dc.Load(dc.GetAppointmentsByResourceQuery(aid));
loadAppts.Completed += (s, a) =>
{
    foreach (Web.Appointment app in loadAppts.Entities)
    {
        foreach (Attendee att in app.Attendees)  //app.Attendees is not there
        {
            Console.WriteLine(att.UserName);
        }
    }
}

I have tried both the FetchStrategy and the simpler Include() method (noted below for reference) to no avail. All I get in the Silverlight project is the top tier Web.Appointment objects. What am I not doing right?

public IQueryable<Web.Appointment> GetAppointmentsByResource(int rscID)
{
    return this.DataContext.Appointments
                .Include(a => a.Appt2Rescs)
                .Include(a => a.Attendees)
                .Where(w => w.Appt2Rescs.Any(r => r.ResourceFK == rscID));
}

1 Answer, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 21 Jun 2013, 02:03 PM
Hello Art,

 Can you please verify that the objects are correctly loaded on your server? It is not impossible that our lazy loading is preventing the objects from being serialized. Can you please try to access one of the objects before returning it to the client and see if that changes the behaviour?

Regards,
Petar
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Tags
Web Services
Asked by
Art Kedzierski
Top achievements
Rank 2
Answers by
PetarP
Telerik team
Share this question
or