Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

ODataController in WebAPI with Custom Entity

$
0
0

Hi,

Am having a table with one column say Code (With this one column I want to create a custom entity with 3 columns and build a JSON is the requirement).. I created a Custom Entity like below

Class TreeView{

string name get;set;

string code get;set;

List<TreeView> subChild  get; set;

}

In my controller am returning like this 

List<TreeView> finalTreeView = new List<TreeView>();  return Ok(finalTreeData.AsQueryable(););

But my JSON is returned like below.

"value": [
{
"@odata.type": "#CustomEntity.TreeView",
"Code": "A",
"Name": "A - Agriculture and Forestry"
}
]

Here is the Problem my JSON not returning the 3rd filed subChild. Concept is  TreeView class is not my Table name. It is purely a custom entity am trying to return as JSON.

Any Idea on this?


Viewing all articles
Browse latest Browse all 4850


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