我想创建一种储存模式,能够表达并利用Linq-To-Sql生成必要的文件。
例如,我有这样的职能:
// Possible criteria
Expression<Func<Purchase,bool>> criteria1 = p => p.Price > 1000;
// Function that should take that criteria and convert to SQL statement
static IEnumerable<Customer> GetCustomers (Expression<Func<Purchase,bool>> criteria)
{
// ...
}
在这项职能方面,我谨将标准转化为使用Linq-To-Sql的LQ声明。
I am aware that you can use DataContext.Log
to see the executed queries and DataContext.GetCommand(query).CommandText
to see the full query before it is executed. However, I would like just a part of the entire expression generated.
我希望完成的工作是,使我的存放处能够把基础技术(Linq-to-Sql, Dapper, 等)抽象化。 这样,我就能够向存放处转达,让它产生正确的声明,并利用正确的技术加以执行。