Pass in an Expression to linq's Select

前端 未结 4 1760
甜味超标
甜味超标 2021-02-13 02:07

This is linq-to-sql

I have a lot of different classes all doing the same query, but projecting the results slightly differently. Ideally I\'d like to b

4条回答
  •  醉话见心
    2021-02-13 02:48

    This will not work at compile-time. Using dynamic stuff you can make it work of course.

    A simple solution is not to use an anonymous type but a custom-made DTO class. Such a DTO class only takes very few lines and is easy to maintain. Usually this is a good solution.

提交回复
热议问题