using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Q1080766
{
class A
{
public string Line1 { get; set; }
public string Line2 { get; set; }
public string Line3 { get; set; }
}
class Program
{
static void Main(string[] args)
{
int num = 1;
var p = Expression.Parameter(typeof(A), "p");
var getp = Expression.MakeMemberAccess(p, typeof(A).GetProperty("Line" + num.ToString()));
var body = Expression.Equal(getp, Expression.Constant("查询的值"));
var lambda = Expression.Lambda<Func<A, bool>>(body, p);
List<A> list = new List<A>();
list.Add(new A { Line1 = "查询的值", Line2 = "", Line3 = "" });
var query = list.AsQueryable().Where(lambda);
foreach (var item in query)
Console.WriteLine(item.Line1);
}
}
}