Posted on: 5/14/2014 12:34:34 PM | Views : 249

How can one Convert linq result to datatable?
I was trying to convert it like below. But is giving error on CopyToDataTable()
public DataTable filSubCategory(Int32 cid) { btDataContext db = new btContext(); var q = from p in db.Bt_ProjectCat join c in db.Bt_ProjectCat on p.CategoryId equals c.ParentCategoryId where c.Disabled == false && c.ParentCategoryId == cid orderby p.CategoryName select new { ParentCategoryID = p.CategoryId, ChildCategoryID = c.CategoryId, ParentCategory = p.CategoryName, ChildCategory = c.CategoryName }; DataTable dtSubCat = q.CopyToDataTable(); return dtSubCat; }

Go to the complete details ...