?: Operator in LINQ Query

后端 未结 5 2094
时光取名叫无心
时光取名叫无心 2021-02-20 15:20
  • How do I utilize a ?: operator in the SELECT clause of a LINQ query? If this can\'t be done, how can I emulate one? The goal is to get a CASE block in my select claus

5条回答
  •  执笔经年
    2021-02-20 16:19

    Really. this question depends on the particular implementation of IQueryable that your linq expression will return. I see that you have db.XXX so are you using linq to sql or some linq to data store? If so, the specific implementation of IQueryable will need to have a way to translate your expression into a store expression. Other than the above comments, some of the other comments are correct that in an anonymous type you must specify a name for each member. This is really your error.

提交回复
热议问题