Browse Source

-

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
9ab46b3132
  1. 2
      Src/Asp.Net/SqlServerTest/Demos/1_Query.cs
  2. 34
      Src/Asp.Net/SqlServerTest/Program.cs
  3. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Method/DefaultDbMethod.cs
  4. 19
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

2
Src/Asp.Net/SqlServerTest/Demos/1_Query.cs

@ -182,6 +182,8 @@ namespace OrmTest.Demo
var getTodayList = db.Queryable<Student>().Where(it => SqlFunc.DateIsSame(it.CreateTime, DateTime.Now)).ToList();
var joinSql = db.Queryable("student", "s").OrderBy("id").Select("id,name").ToPageList(1, 2);
var getDay1List = db.Queryable<Student>().Where(it=>it.CreateTime.Value.Hour==1).ToList();
}
public static void Page()
{

34
Src/Asp.Net/SqlServerTest/Program.cs

@ -17,23 +17,23 @@ namespace OrmTest
{
static void Main(string[] args)
{
// /***Unit Test***/
new Select(1).Init();
new Field(1).Init();
new Where(1).Init();
new Method(1).Init();
new JoinQuery(1).Init();
new SingleQuery(1).Init();
new SelectQuery(1).Init();
new AutoClose(1).Init();
new Insert(1).Init();
new Delete(1).Init();
new Update(1).Init();
new Mapping(1).Init();
new DataTest(1).Init();
new EnumTest(1).Init();
/***Performance Test***/
new SqlSugarPerformance(100).Select();
//// /***Unit Test***/
//new Select(1).Init();
//new Field(1).Init();
//new Where(1).Init();
//new Method(1).Init();
//new JoinQuery(1).Init();
//new SingleQuery(1).Init();
//new SelectQuery(1).Init();
//new AutoClose(1).Init();
//new Insert(1).Init();
//new Delete(1).Init();
//new Update(1).Init();
//new Mapping(1).Init();
//new DataTest(1).Init();
//new EnumTest(1).Init();
///***Performance Test***/
//new SqlSugarPerformance(100).Select();
/***Demo***/
OrmTest.Demo.Query.Init();

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/Method/DefaultDbMethod.cs

@ -153,7 +153,7 @@ namespace SqlSugar
{
var parameter = model.Args[0];
var parameter2 = model.Args[1];
return string.Format(" ({0}({1})) ", parameter2.MemberName, parameter.MemberName);
return string.Format(" DateName({0},{1}) ", parameter2.MemberName, parameter.MemberName);
}
public virtual string ToInt32(MethodCallExpressionModel model)

19
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

@ -18,6 +18,7 @@ namespace SqlSugar
var isBool = expression.Type == PubConst.BoolType;
var isValueBool = isValue && isBool && parameter.BaseExpression == null;
var isLength = expression.Member.Name == "Length" && (expression.Expression as MemberExpression).Type == PubConst.StringType;
var isDateValue = expression.Member.Name.IsIn(Enum.GetNames(typeof(DateType))) && (expression.Expression as MemberExpression).Type == PubConst.DateType;
if (isLength)
{
var oldCommonTempDate = parameter.CommonTempData;
@ -36,6 +37,24 @@ namespace SqlSugar
parameter.CommonTempData = oldCommonTempDate;
return;
}
else if (isDateValue) {
var name = expression.Member.Name;
var oldCommonTempDate = parameter.CommonTempData;
parameter.CommonTempData = CommonTempDataType.Result;
this.Expression = expression.Expression;
var isConst = this.Expression is ConstantExpression;
this.Start();
var result = this.Context.DbMehtods.DateValue(new MethodCallExpressionModel()
{
Args = new List<MethodCallExpressionArgs>() {
new MethodCallExpressionArgs() { IsMember = !isConst, MemberName = parameter.CommonTempData, MemberValue = null },
new MethodCallExpressionArgs() { IsMember = true, MemberName = name, MemberValue = name }
}
});
base.AppendMember(parameter, isLeft, result);
parameter.CommonTempData = oldCommonTempDate;
return;
}
else if (isValueBool)
{
isValue = false;

Loading…
Cancel
Save