Category Table:
ID => int, primary key
CategoryName => varchar
ParentCategoryID => int , nullable
Generate following json data format:
[{
"id":1,
"name":"Root",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>",
"children":[{
"id":2,
"name":"Horoscope",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>",
"children":[{
"id":21,
"name":"Daily",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>",
"children":[{
"id":211,
"name":"Aries",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>"
},{
"id":212,
"name":"Taurus",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>"
}]
},{
"id":22,
"name":"Weekly",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>",
"children":[{
"id":221,
"name":"Gemini",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>"
},{
"id":222,
"name":"Aries",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>"
},{
"id":223,
"name":"Taurus",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>"
}]
}]
},{
"id":3,
"name":"News",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>",
"children":[{
"id":31,
"name":"Sports",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>"
},{
"id":32,
"name":"Interantional",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>"
},{
"id":33,
"name":"Entertaintment",
"Edit":"<a href='Edit/id'>edit.png</a>",
"Delete":"<a href='Delete/id'>delete.png</a>"
}]
}]
}]
I have Jquery TreeGrid Plugins which needs above json format. How Can I generate above json data from category table of database and return json data in controller action. I have use entity framework for model.