public IQueryable<TEntity> Find<TEntity>(TEntity obj) where TEntity : class
BindingFlags.Instance); //构造初始的query
IQueryable<TEntity> query = this.GetTable<TEntity>().AsQueryable<TEntity>();
//遍历每个property
foreach (PropertyInfo p in properties)
<TEntity, bool>>(filter, param); query = query.Where(pred);
}
}
}
}
return query;
}
调用:
Customer c = new Customer();
c.City = "London";
c.Phone = "23236133";
var q = db.Find<Customer>(c).ToList();