//查询实体
public class ItemClass{
public string field1{get;set;}
public string field2{get;set;}
public string field3{get;set;}
public string field4{get;set;}
public string field5{get;set;}
}
//此变量来自客户端(动态,可能等于ItemClass属性,可能更少)
var fields = "field1,field2,field3";
// linq查询
var query =from q in items
select new {
// can i select field dynamic by variable "fields"
// as below
field1=q.field1,
field2=q.field2,
field3=q.field3
};
我想查询数据并通过linq选择项目动态。有谁能够帮我?