日期:2014-05-20 浏览次数:21118 次
var db = new ExamdaDbContext(EnmDb.ExamSystem_Set);
IQueryable<ExpressionClassModel> cities = db.ExpresstionClass;
ParameterExpression param = Expression.Parameter(typeof(ExpressionClassModel), "c");
Expression left = Expression.Property(param, typeof(ExpressionClassModel).GetProperty("Name"));
Expression right = Expression.Constant("心情");
Expression filter = Expression.Equal(left, right);
var result = db.ExpresstionClass.Where(Expression.Lambda<Func<ExpressionClassModel, bool>>(filter, param));
var query = from x in MyDbContext()
select x;
if(name !=null)
query = from x in query
where x.Name == name
select x;