用于C#的SqlBuilder()比较where条件中的datetime

时间:2018-05-04 18:45:33

标签: c# sql .net sqlbuilder

var builder = new SqlBuilder();
var sqlQuery = @"Select * From xxxxTable /**where**/";
var template = builder.AddTemplate(sqlQuery);

builder.Where("xxx1= @xxx1", new { xxx1= xxx1});
builder.Where("convert(date,xxx2) < convert(date,GETDATE())"); // compare with sql server current date is Okay!
builder.Where("convert(date,xxx3) < convert(date,@xxx3)", new {xxx3 = xxx3}); // compare with parameter date is not okay!


using (var connection = Db.GetConnection(xx_ConnectionString_xx))
{
return connection.Query<xxModel>(template.RawSql,template.Parameters).FirstOrDefault();
}

比较日期时间列值 SqlBuilder使用有任何想法。

谢谢....

0 个答案:

没有答案