LINQ to Entities - Dynamic Column Selection

I can create a select query that only extracts specific columns (static in code) for LINQ for objects

from Example in new Enities.Table 
select new { Example.Column1. Example.Column2, ... }

But I can’t understand how to choose the dynamics of Column1, Column2 (for example, from the string []). Thanks

+5
source share
1 answer

The standard LINQ does not support this - you must download the library called Dynamic LINQ or create the expression tree manually. Dynamic LINQ allows you to call queries like:

var query = Entities.Table.Select("new(Column1,Column2)");

, LINQ - . Entity SQL LINQ .

+5

All Articles