开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜