Difficulty with DataLoadOptions - non deferred loading.

Difficulty with DataLoadOptions - non deferred loading.

Postby curelom » Mon 14 Jun 2010 17:21

I'm having difficulty loading in a detail table at the same time as master data. If I use the below query using "select c", the detail data is loaded. I can see in the query generated an outer join to the detail table, which is what I want, however whenever I use an anonymous type "select new { c.Data, c.WeekStartDate, c.TimeId, c.DmdbNotes, c.GeographyId, c.CustomerNum, c.Sku };"
the detail table is not loaded and is not part of the query. This query brings in tens of thousands of rows and I only have a small network pipe to send it, so I can't afford bringing all the header data for each of the detail datapoints. I also have to save the data as the users want to access this offline, so I can't use deferred loading either.

using Devart 5.70.140.0

Thank you

Code: Select all
//load notes from the database at the same time we load the other data.
mgr.DataContext.DeferredLoadingEnabled = false;
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith(c => c.CommitmentViews);
dlo.LoadWith(c => c.DmdbNotes);
mgr.DataContext.LoadOptions = dlo;

//get datapoints - detail data
var fd = from c in mgr.DataContext.CommitmentViews.LoadWith(cv => cv.DmdbNotes)
where l.Contains(c.SalesRepId) //u.UserId)
orderby
     c.CustomerName, c.CustomerNum,
     c.Sku,
     c.WeekStartDate
select new { c.Data, c.WeekStartDate, c.TimeId, c.DmdbNotes, c.GeographyId, c.CustomerNum, c.Sku };
curelom
 
Posts: 19
Joined: Wed 17 Feb 2010 21:10

Kludge

Postby curelom » Tue 15 Jun 2010 20:21

To resolve this, I had to create another entity class containing just the columns I wanted to import and used that. It works, though it clutters and complicates the data model.
curelom
 
Posts: 19
Joined: Wed 17 Feb 2010 21:10

Postby AndreyR » Wed 16 Jun 2010 15:39

You have found an acceptable solution. LINQ to SQL does not accept LoadWith usage with non-Entity types.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for Oracle