cutom query
-
I have a table MyTable (comId, groupId, versionId) that is bound to a grid using code. The default connection generated by domain services works fine return this.ObjectContext.MyTable; but I modified the return statement to get one column only return this.ObjectContext.MyTable.Include("groupId"); This statement compiles correct but returns an error unhandle error Manage Runtime System.ServiceMode.DomainService.Client.DomainOperation Exception Any help is greatly appreciated
-
I have a table MyTable (comId, groupId, versionId) that is bound to a grid using code. The default connection generated by domain services works fine return this.ObjectContext.MyTable; but I modified the return statement to get one column only return this.ObjectContext.MyTable.Include("groupId"); This statement compiles correct but returns an error unhandle error Manage Runtime System.ServiceMode.DomainService.Client.DomainOperation Exception Any help is greatly appreciated
If you would like to get only the groupId column, you need to use Select(t => t.groupId). Include("EntityName1.EntityName2...") instructs EF to include data from another table, that is directly or indirectly linked to the one you're querying.
-
I have a table MyTable (comId, groupId, versionId) that is bound to a grid using code. The default connection generated by domain services works fine return this.ObjectContext.MyTable; but I modified the return statement to get one column only return this.ObjectContext.MyTable.Include("groupId"); This statement compiles correct but returns an error unhandle error Manage Runtime System.ServiceMode.DomainService.Client.DomainOperation Exception Any help is greatly appreciated
Read more about
Include
function in EF.[^]
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
-
If you would like to get only the groupId column, you need to use Select(t => t.groupId). Include("EntityName1.EntityName2...") instructs EF to include data from another table, that is directly or indirectly linked to the one you're querying.
I could not complete the return statement as your suggestion: public IQueryable<compntMtx> GetCompntMtxes(int components) { return this.ObjectContext.compntMtxes.Select(t =>t; t.compName)?? } I cannot add an "Include" after the select (e.g. Select(t =>t;t; t.compName).Include(myEntityName) thank you in advance for the help
-
I could not complete the return statement as your suggestion: public IQueryable<compntMtx> GetCompntMtxes(int components) { return this.ObjectContext.compntMtxes.Select(t =>t; t.compName)?? } I cannot add an "Include" after the select (e.g. Select(t =>t;t; t.compName).Include(myEntityName) thank you in advance for the help
If you are building a projection that returns a single column, the return type of your method would be IEnumerable<MyColumnType>, not IQueryable<compntMtx>. You do not need to use "Include" at all.
-
If you are building a projection that returns a single column, the return type of your method would be IEnumerable<MyColumnType>, not IQueryable<compntMtx>. You do not need to use "Include" at all.