New Posts New Posts RSS Feed: WinRT, Code First - 'Include' clause does not work.
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

WinRT, Code First - 'Include' clause does not work.

 Post Reply Post Reply
Author
zbig View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Oct-2012
Posts: 28
Post Options Post Options   Quote zbig Quote  Post ReplyReply Direct Link To This Post Topic: WinRT, Code First - 'Include' clause does not work.
    Posted: 27-Jul-2013 at 1:49pm
Hi,

I am using EF Code First with fluent mapping. When I'm executing query which contains 'Include' clause, related entities are not retrieved.

Please find attached a trivial application (package libraries removed to be able to attach the solution).The solution includes only three entities: User, Role, UserRole (many to many relational table).

I think, I made everything what is necessary to get related entities (according to the documentation), but after executing query (MainPage.xaml.cs):


var usersQuery = appTestEntityManager
               .Users
               .Include(u => u.UserRoles);

var result = await appTestEntityManager.ExecuteQueryAsync(usersQuery);


the 'result' variable does not contains related 'UserRoles'.

Database is properly created and filled out by sample data during executing query. Everything seems to be ok ... I have no idea what is wrong.

Thanks in advance for any advice.

AppTest.zip
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jul-2013 at 12:24pm
It looks like DevForce has a problem with the private setter on the User.UserRoles navigation property.  It's probably eating the error and should not.  You won't be able to use a private accessor, but in theory internal should be allowed, although that too doesn't seem to be working and is something we need to look at.
 
To work around the issue, you can define the property like this:
 
  public RelatedEntityList<UserRole> UserRoles { get { return null; } }
 
or this:
 
  public RelatedEntityList<UserRole> UserRoles { get; set; }
 
More on defining navigation properties in Code First here - http://drc.ideablade.com/devforce-2012/bin/view/Documentation/code-first-entity-classes.
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down