c# - ASP.Net Web API returns null instead of non-simple properties -


I have just begun trying to produce some test ASP .NET Web API app, and there is a problem: / P>

I have the model:

  public class property {public entry ID (Received); Set; } [Foreign ("Assettype")] Public Insurance Assetize ID {Receipt; Set; } Public Access Type Asset {get; Set; }} Public class asset type {public entry id (get; set;} public string name {get} set;}}  

and try to get all records of DB

< Pre> public IEnumerable & lt; Asset & gt; GetAssets () {return db.Assets.AsEnumerable ();}

I get some strange results (at least my For this, it is weird). Instead of expanding the setset - I get zero:

   gt0; AssetTypeId> 1 & lt; / AssetTypeId & gt; & Lt; id = 1  gt; AssetType i: zero = "true" />  

I have checked my DB - pointing in to correct the property type in this, both the Assetipid and Assetep regions The only way to expand the field is by changing the following GetAssets:

  Public HTTPRPS Pacemus GetAssets () {Return Request. Create Response (HTTPTitas.CO.OK, Db.asset.in clude ("type") ToList ()). }  

But I think I am very wrong because in fact I have dozens of 'complex' areas, some of which are nested, and connect them through "." ("Type") "- Wrong.

So the question is - Where did I get an error? How can I get my data properly?

< P>

This is due to sluggish loading.

Lazy loading is a concept where we delay loading the object As far as we need it.

When you did .include , then that data was actually loaded and you can get it. < / P>

P>

There is no default configuration for curious loading. You should always define which should include some reusable method that will be included to include adding.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -