add dummy column in LINQ fetch query
How to return the List in LINQ query while adding a dummy column, How to return qry as LIST.
public static List<MSDNMagazine.emp> FetchEmp()
{
try
{
MSDNMagazine.JsonDataContext context = new MSDNMagazine.JsonDataContext();
var qry = from p in context.emps
select开发者_如何学C new
{
emp_cod = p.emp_cod,
emp_nam = p.emp_nam,
test = "0"
};
return (List< >)qry;
}
catch (Exception ex)
{
throw ex;
}
}
select new emp //the name of the class
{
emp_cod = p.emp_cod,
emp_nam = p.emp_nam,
test = "0"
};
return qry.ToList();
Use the ToList() Extension method.
return qry.ToList();
精彩评论