8,497
社区成员
发帖
与我相关
我的任务
分享
string log_user = Request.Form["log_user"];
string log_org = Request.Form["log_org"];
ParameterExpression parameter1 = Expression.Parameter(typeof(SJJH_DLQX_LOG), "D");
ConstantExpression constant1 = Expression.Constant(log_user);
ConstantExpression constant2 = Expression.Constant(log_org);
var query1 = Expression.Call(Expression.Default(typeof(string)), typeof(string).GetMethod("Contains"), Expression.Default(typeof(string)));
var query2 = Expression.Call(Expression.Default(typeof(string)), typeof(string).GetMethod("Contains"), Expression.Default(typeof(string)));
if (!string.IsNullOrEmpty(log_user))
{
query1 = Expression.Call(Expression.PropertyOrField(parameter1, "log_user"), typeof(string).GetMethod("Contains"), constant1);
}
if (!string.IsNullOrEmpty(log_org))
{
query2 = Expression.Call(Expression.PropertyOrField(parameter1, "log_org"), typeof(string).GetMethod("Contains"), constant2);
}
var query = Expression.And(query1, query2);
var lambda1 = Expression.Lambda<Func<SJJH_DLQX_LOG, Boolean>>(query, parameter1);
lambda1.Compile();
temp = db.Set<T>().Where<T>(whereLambda);
total = temp.Count(); // 这一行报错:未将对象引用到实例