I'm trying to retrieve only current object ,not including children objects:
FetchStrategy fetchStrategy = new FetchStrategy();
fetchStrategy.MaxFetchDepth = 1;
fetchStrategy.MaxResultsLimit = 1;
dbContext.FetchStrategy = fetchStrategy ;
IEnumerable<Sample> samples = dbContext.Sample.Where(s => s.SampleBarcode == sampleBarcode);
but result includes many children object,such as Sample.SampleItem ...
Tell what should I do .
Thanks
Dgyang
5 Answers, 1 is accepted
Initially only the current object is being retrieved. If you try to access some of the navigation members of this object, additional calls to the database will be made in order to retrieve the necessary information for them. This means that the navigation members are loaded on-demand.
Hope that helps.
Damyan Bogoev
the Telerik team
Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
var ctx =
new
FluentModel();
ctx.FetchStrategy =
new
FetchStrategy {MaxResultsLimit = 1, MaxFetchDepth = 1};
ctx.FetchStrategy.LoadWith((Group t) => t.Users);
var result = ctx.Groups.ToList();
You need to use the Take Linq Extension method in order to achieve that goal.
Hope that helps.
Damyan Bogoev
Telerik
I want to limit that number of fetching linked records for each container record, because a fetch may be large (1 million users for each group).
I am afraid the MaxResultsLimit setting is not respected during the Linq query processing, but only for OQL one.
You need to use the Take / Limit Linq extension methods to achieve this goal.
Damyan Bogoev
Telerik