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

Error in lambda expression in LoadWith FetchStrategy

1 Answer 83 Views
Development (API, general 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.
itzik
Top achievements
Rank 1
itzik asked on 18 Jun 2012, 07:54 AM
I tried to order link table with fetch strategy and got exception:

Telerik.OpenAccess.FetchOptimization.FetchStrategy fetchStrategy = new Telerik.OpenAccess.FetchOptimization.FetchStrategy();
fetchStrategy.LoadWith<Project>(p => p.Matrices.OrderBy(x => x.Position));            
dbContext.FetchStrategy = fetchStrategy;

exception:
Invalid FetchStrategy path expression, must be property/field access on persistent types or Select() on persistent collections.
Parameter name: expression
Actual value was p.Matrices.OrderBy(x => x.Position).

please advice

Thanks

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 19 Jun 2012, 01:14 PM
Hello itzik,

This syntax is not allowed - the LoadWith method is meant to be used only in order to specify a navigation property (referenced object or collection), which should be loaded together with the root object in a single SQL query. Any additional operations are not expected.
If you would like to specify an order for the objects retrieved from the database, you should do that in the linq query executed against the context class of your domain model.

Greetings,
Alexander
the Telerik team
OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
Tags
Development (API, general questions)
Asked by
itzik
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or