Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

First time After Inserting a data to the Data base the Navigation properties are null

$
0
0

Hi!

When I am inserting data into the empty table and retrieving the data the Navigation property is null.

Eg. I have a table called Inventory and it has a Navigation properties called Type and Status.

without disposing the DbContext I am retrieving the data by passing the id.

at this point, the status and type models are null thought it has data.

Inventory: Inv_id Inv_nme type_id status_id

when i say : inventory.type.type_name

I am getting an error saying null instance of an object.

To avoid the issue temporarily Eager Loading method using Include to call the submodels:

By using lazy load how can i get the navigation properties data like  :

inventory.type.type_name

inventory.status.status_name

 


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>