Friday, November 16, 2012

Return Some/Specific Column from a table or Joined Table using LINQ

How to fetch some column from table in linq


[HttpGet]
        public JsonResult ShowAllMstStocklistScheme()
        {

            var v = PR.ShowAllMstStocklistScheme().Select(p => new { p.ID, p.Scheme });
            return Json(v, JsonRequestBehavior.AllowGet);
        }

in code "new { p.ID, p.Scheme }" is declare column name or table property name which you want to access through this query.

Some problem arise when we going to bind dropdown in kendo from a table which has a foreign key realtion. That time we need to access specific column from table.

we can use this way of return from LINQ data.  

No comments:

SQL Optimization

  SQL Optimization  1. Add where on your query  2. If you remove some data after the data return then remove the remove condition in the sel...