@@ -125,7 +125,7 @@ public static IQueryable<TSource> Filter<TSource>(this IQueryable<TSource> sourc
125
125
throw new JsonApiException ( "400" , $ "Could not cast { filterQuery . PropertyValue } to { property . PropertyType . Name } ") ;
126
126
}
127
127
}
128
- public static IQueryable < TSource > Select < TSource > ( this IQueryable source , string [ ] columns )
128
+ public static IQueryable < dynamic > Select < TSource > ( this IQueryable < TSource > source , string [ ] columns )
129
129
{
130
130
var sourceType = source . ElementType ;
131
131
@@ -137,13 +137,13 @@ public static IQueryable<TSource> Select<TSource>(this IQueryable source, string
137
137
var bindings = columns . Select ( column => Expression . Bind (
138
138
resultType . GetProperty ( column ) , Expression . PropertyOrField ( parameter , column ) ) ) ;
139
139
140
+ // { new Model () { Property = model.Property } }
140
141
var body = Expression . MemberInit ( Expression . New ( resultType ) , bindings ) ;
141
142
142
- var selector = Expression . Lambda ( body , parameter ) ;
143
+ // { model => new TodoItem() { Property = model.Property } }
144
+ var selector = Expression . Lambda < Func < TSource , dynamic > > ( body , parameter ) ;
143
145
144
- return source . Provider . CreateQuery < TSource > (
145
- Expression . Call ( typeof ( Queryable ) , "Select" , new Type [ ] { sourceType , resultType } ,
146
- source . Expression , Expression . Quote ( selector ) ) ) ;
146
+ return source . Select ( selector ) ;
147
147
}
148
148
}
149
149
}
0 commit comments