How to convert LINQ query result to List?

前端 未结 5 1447
花落未央
花落未央 2020-12-06 09:51

I need to convert linq query result to list. I tried the following code:

var qry = from a in obj.tbCourses
                    


        
5条回答
  •  借酒劲吻你
    2020-12-06 09:52

    What you can do is select everything into a new instance of Course, and afterwards convert them to a List.

    var qry = from a in obj.tbCourses
                         select new Course() {
                             Course.Property = a.Property
                             ...
                         };
    
    qry.toList();
    

提交回复
热议问题