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

DataAccess and Navigation

1 Answer 57 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rich
Top achievements
Rank 1
Rich asked on 17 Nov 2014, 05:34 AM
I'm new to the DataAccess tool, and i've recently been given the task of converting a vb project to a c# project.

I've got the data model moved and it seems correct, at least when i look at it, it has the the properties, implementation and navigation. and they look correct.

I can't seem to access the Navigation portion. when i call the code.  the base table properties are all available, but the navigation is missing, even though visible in the model.

The vb portion works fine but not the c# version.   Thoughts on what i should look at/might be wrong?

this works fine:
DBContext.WebApps.FirstOrDefault((WebApp f) => f.appGUID.ToString() == WebAppsGuid);

or any time the properties are used, but if 

DBContext.WebSessions.FirstOrDefault((WebSession f) => f.WebAppId == qWebApp.Id & f.WebUser.AspNetUserId == CurrentClient.Id & f.Expired == 0);

specifically: f.WebUser.AspNetUserId when i try to use the navigation, it's just not there to use.

Thoughts on what i should look at/might be wrong?

1 Answer, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 19 Nov 2014, 04:39 PM
Hello Rich,

In the lamba expression, you are checking for the "AspNetUserId" property of the reference navigation property without checking if the reference WebUser exists at all. Also you are using the '&' operator instead the '&&' operator which will evaluate the entire statement, instead of returning false if the first comparison fails.

Could you try to replace the lambda expression with this code:
DBContext.WebSessions.FirstOrDefault((WebSession f) => f.WebAppId == qWebApp.Id && f.WebUser != null && f.WebUser.AspNetUserId == CurrentClient.Id && f.Expired == 0);

I hope that helps. If any other questions arise, do not hesitate to contact us again.

Regards,
Boris Georgiev
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Data Access Free Edition
Asked by
Rich
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Share this question
or