Pass in an Expression to linq's Select

前端 未结 4 1768
甜味超标
甜味超标 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 03:11

    IdeaBlade has a ProjectionSelector class that you can use to abstract your projections. When you need to construct a projection query but you don't know the types involved at compile time, you can create an instance of the ProjectionSelector class and pass in the type information at runtime.

    The class, and sample code, can be found here:

    Create dynamic "Select", "SelectMany" and "GroupBy" clauses
    http://drc.ideablade.com/xwiki/bin/view/Documentation/dynamic-projection

提交回复
热议问题