mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 04:35:29 +08:00
ok
This commit is contained in:
parent
a928677842
commit
4553bae9b0
Binary file not shown.
@ -20,23 +20,27 @@ namespace OrmTest.ExpressionTest
|
||||
single();
|
||||
Multiple();
|
||||
singleDynamic();
|
||||
MultipleDynamic();
|
||||
MultipleDynamic();
|
||||
}
|
||||
DateTime e = DateTime.Now;
|
||||
Console.WriteLine("Count: "+ count + "\r\nTime: "+(e-b).TotalSeconds+ " Seconds ");
|
||||
Console.WriteLine("Count: " + count + "\r\nTime: " + (e - b).TotalSeconds + " Seconds ");
|
||||
}
|
||||
|
||||
private static void Multiple()
|
||||
{
|
||||
Expression<Func<Student,School, object>> exp = (it,school) => new Student() { Name = "a", Id = it.Id, SchoolId = school.Id };
|
||||
Expression<Func<Student, School, object>> exp = (it, school) => new Student() { Name = "a", Id = it.Id, SchoolId = school.Id,TestId=it.Id+1 };
|
||||
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.SelectMultiple);
|
||||
expContext.Resolve();
|
||||
var selectorValue = expContext.Result.GetString();
|
||||
var pars = expContext.Parameters;
|
||||
if (selectorValue.Trim() != " @constant1 AS Name , it.Id AS Id , school.Id AS SchoolId ".Trim())
|
||||
{
|
||||
throw new Exception("Multiple Error");
|
||||
}
|
||||
}
|
||||
private static void MultipleDynamic()
|
||||
{
|
||||
Expression<Func<Student, School, object>> exp = (it, school) => new{ Name = "a", Id = it.Id/2, SchoolId = school.Id };
|
||||
Expression<Func<Student, School, object>> exp = (it, school) => new { Name = "a", Id = it.Id / 2, SchoolId = school.Id };
|
||||
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.SelectMultiple);
|
||||
expContext.Resolve();
|
||||
var selectorValue = expContext.Result.GetString();
|
||||
|
@ -20,5 +20,6 @@ namespace OrmTest.Models
|
||||
|
||||
[SugarColumn(MappingKeys = "id,SchoolId")]
|
||||
public virtual School School { get; set; }
|
||||
public int TestId { get; set; }
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -44,26 +44,45 @@ namespace SqlSugar
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
MemberAssignment memberAssignment = (MemberAssignment)binding;
|
||||
var memberName = memberAssignment.Member.Name;
|
||||
var item = memberAssignment.Expression;
|
||||
if (item.NodeType == ExpressionType.Constant || (item is MemberExpression) && ((MemberExpression)item).Expression.NodeType == ExpressionType.Constant)
|
||||
{
|
||||
base.Expression = item;
|
||||
base.Start();
|
||||
string parameterName = this.Context.SqlParameterKeyWord + "constant" + i;
|
||||
parameter.Context.Result.Append(parameterName);
|
||||
parameter.Context.Result.Append(base.Context.GetAsString(memberName, parameterName));
|
||||
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.CommonTempData));
|
||||
}
|
||||
else if (item is MemberExpression)
|
||||
{
|
||||
base.Expression = memberAssignment.Expression;
|
||||
base.Start();
|
||||
if (base.Context.Result.IsLockCurrentParameter == false)
|
||||
{
|
||||
base.Context.Result.CurrentParameter = parameter;
|
||||
base.Context.Result.IsLockCurrentParameter = true;
|
||||
parameter.IsAppendTempDate();
|
||||
base.Expression = item;
|
||||
base.Start();
|
||||
parameter.IsAppendResult();
|
||||
base.Context.Result.Append(base.Context.GetAsString(memberName, parameter.CommonTempData.ObjToString()));
|
||||
base.Context.Result.CurrentParameter = null;
|
||||
}
|
||||
}
|
||||
else if (item is BinaryExpression)
|
||||
{
|
||||
base.Expression = item;
|
||||
parameter.CommonTempData = "simple";
|
||||
base.Start();
|
||||
parameter.CommonTempData = null;
|
||||
if (base.Context.Result.IsLockCurrentParameter == false)
|
||||
{
|
||||
base.Context.Result.CurrentParameter = parameter;
|
||||
base.Context.Result.IsLockCurrentParameter = true;
|
||||
parameter.IsAppendTempDate();
|
||||
base.Expression = item;
|
||||
parameter.CommonTempData = "simple";
|
||||
base.Start();
|
||||
parameter.CommonTempData = null;
|
||||
parameter.IsAppendResult();
|
||||
base.Context.Result.Append(base.Context.GetAsString(memberName, parameter.CommonTempData.ObjToString()));
|
||||
base.Context.Result.CurrentParameter = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user