LINQ - Add property to results

前端 未结 5 1097
日久生厌
日久生厌 2020-12-18 23:15

Is there a way to add a property to the objects of a Linq query result other than the following?

var query = from x in db.Courses
                select new
         


        
5条回答
  •  一个人的身影
    2020-12-18 23:57

    I suppose you could return a new object composed of the new property and the selected object, like:

    var query = from x in db.Courses
                    select new
                    {
                        Course x,
                        NewProperty = true
                    };
    

提交回复
热议问题