Code collation

This commit is contained in:
sunkaixuan
2017-06-19 02:09:30 +08:00
parent 6ec185b418
commit f0a5e4dc2b
2 changed files with 15 additions and 2 deletions

View File

@@ -158,7 +158,16 @@ namespace SqlSugar
var type = value.GetType(); var type = value.GetType();
if (type == PubConst.DateType) if (type == PubConst.DateType)
{ {
return "'" + value.ObjToDate().ToString("yyyy-MM-dd hh:mm:ss.fff") + "'"; var date = value.ObjToDate();
if (date < Convert.ToDateTime("1900-1-1"))
{
date = Convert.ToDateTime("1900-1-1");
}
return "'" + date.ToString("yyyy-MM-dd hh:mm:ss.fff") + "'";
}
else if (type == PubConst.BoolType)
{
return value.ObjToBool() ? "1" : "0";
} }
else if (type == PubConst.StringType || type == PubConst.ObjType) else if (type == PubConst.StringType || type == PubConst.ObjType)
{ {
@@ -169,7 +178,7 @@ namespace SqlSugar
return "N'" + value.ToString() + "'"; return "N'" + value.ToString() + "'";
} }
} }
} }
#endregion #endregion
} }
} }

View File

@@ -258,6 +258,10 @@ namespace SqlSugar
} }
return "'" + date.ToString("yyyy-MM-dd hh:mm:ss.fff") + "'"; return "'" + date.ToString("yyyy-MM-dd hh:mm:ss.fff") + "'";
} }
else if (type == PubConst.BoolType)
{
return value.ObjToBool() ? "1" : "0";
}
else if (type == PubConst.StringType || type == PubConst.ObjType) else if (type == PubConst.StringType || type == PubConst.ObjType)
{ {
return "N'" + value.ToString().ToSqlFilter() + "'"; return "N'" + value.ToString().ToSqlFilter() + "'";