views:

35

answers:

2

Hello,

I set an object entity with a stored procedure, but the navigation properties are always equals at null ...

The aim is to include or join an external entity.

Any idea ?

Thanks

A: 

You have to "load" your navigation properties before accessing them. If the navigation is a collection, use

yourNavigationPropertyName.Load();

if it's a single object, use the reference property associated :

yourNavigationPropertyNameReference.Load();

Later in your development, you should meet an usual related problem. I suggest you to take a look on this post, which deals with entity framework lazy loading :

http://stackoverflow.com/questions/1710731/ado-net-entity-framework-isloaded-and-load/2239967#2239967

Proviste
It's a single object, I will use the reference property associated, thanks.My issue is all foreign keys (navigation properties) are null when I set the object entity with the stored procedure, so I can't make a "load".I don't know why ...My Code :var sp = context.GetUserEntityTransactions(SesameId);List<Transaction> transations = new List<Transaction>(sp.ToList());The transations foreign keys are null
lu2vik
What about trying sp.Load();List transations = new List(sp.ToList());?
Proviste
A: 

It's a single object, I will use the reference property associated, thanks. My issue is all foreign keys (navigation properties) are null when I set the object entity with the stored procedure, so I can't make a "load". I don't know why ...

My Code :

var sp = context.GetUserEntityTransactions(SesameId); 

List transations = new List(sp.ToList());

The transations foreign keys are null

lu2vik