How to convert LINQ query result to List?

前端 未结 5 1454
花落未央
花落未央 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 10:10

    You need to somehow convert each tbcourse object to an instance of course. For instance course could have a constructor that takes a tbcourse. You could then write the query like this:

    var qry = from c in obj.tbCourses
              select new course(c);
    
    List lst = qry.ToList();
    

提交回复
热议问题