日期:2014-05-20  浏览次数:20949 次

Linq to sql 查询结果返回问题
C# code
    public List<Grade> GetGrade()
        {
            var x = from g in context.Grade
                    where g.GradeName == "123"
                    select new { 年级 = g.GradeId };
     
            return ???;
        }



能否转成 Grade类型集合返回呢?

------解决方案--------------------
public List<Grade> GetGrade()
{
var x = from g in context.Grade
where g.GradeName == "123"
select new Grade{ 年级 = g.GradeId };

return x.ToList();
}