mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Aggregate function BUG
This commit is contained in:
parent
e80a46b5f5
commit
89c3d0f174
@ -25,10 +25,40 @@ namespace OrmTest.UnitTest
|
||||
Q3();
|
||||
Q4();
|
||||
q5();
|
||||
q6();
|
||||
q7();
|
||||
}
|
||||
base.End("Method Test");
|
||||
}
|
||||
|
||||
private void q6()
|
||||
{
|
||||
using (var db = GetInstance())
|
||||
{
|
||||
var join6 = db.Queryable<Student, School>((st, sc) => new object[] {
|
||||
JoinType.Left,st.SchoolId==sc.Id
|
||||
}).Select((st, sc) => new ViewModelStudent { Name = st.Name, SchoolId = SqlFunc.AggregateMin(sc.Id) }).ToSql();
|
||||
|
||||
string sql = @"SELECT [st].[Name] AS [Name] , MIN([sc].[Id]) AS [SchoolId] FROM [STudent] st Left JOIN School sc ON ( [st].[SchoolId] = [sc].[Id] ) ";
|
||||
base.Check(sql, null, join6.Key, null, "join 6 Error");
|
||||
}
|
||||
}
|
||||
|
||||
private void q7()
|
||||
{
|
||||
using (var db = GetInstance())
|
||||
{
|
||||
var join7 = db.Queryable<Student, School>((st, sc) => new object[] {
|
||||
JoinType.Left,st.SchoolId==sc.Id
|
||||
}).Select((st, sc) => new ViewModelStudent { Name = st.Name, SchoolId = SqlFunc.AggregateMin(sc.Id*1) }).ToSql();
|
||||
|
||||
string sql = @"SELECT [st].[Name] AS [Name] , MIN(( [sc].[Id] * @Id0 )) AS [SchoolId] FROM [STudent] st Left JOIN School sc ON ( [st].[SchoolId] = [sc].[Id] ) ";
|
||||
base.Check(sql, new List<SugarParameter>() {
|
||||
new SugarParameter("@Id0",1)
|
||||
}, join7.Key, join7.Value, "join 7 Error");
|
||||
}
|
||||
}
|
||||
|
||||
private void q5()
|
||||
{
|
||||
using (var db = GetInstance())
|
||||
|
@ -174,7 +174,8 @@ namespace SqlSugar
|
||||
{
|
||||
var appendValue = this.Context.SqlParameterKeyWord + ExpressionConst.Const + Context.ParameterIndex;
|
||||
Context.ParameterIndex++;
|
||||
if (value != null && value.GetType().IsEnum()) {
|
||||
if (value != null && value.GetType().IsEnum())
|
||||
{
|
||||
value = Convert.ToInt64(value);
|
||||
}
|
||||
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
|
||||
@ -204,7 +205,7 @@ namespace SqlSugar
|
||||
protected string AppendParameter(object paramterValue)
|
||||
{
|
||||
string parameterName = this.Context.SqlParameterKeyWord + "constant" + this.Context.ParameterIndex;
|
||||
this.Context.ParameterIndex++;;
|
||||
this.Context.ParameterIndex++; ;
|
||||
this.Context.Parameters.Add(new SugarParameter(parameterName, paramterValue));
|
||||
return parameterName;
|
||||
}
|
||||
@ -254,7 +255,7 @@ namespace SqlSugar
|
||||
|
||||
protected void ResolveNewExpressions(ExpressionParameter parameter, Expression item, string asName)
|
||||
{
|
||||
if (item.NodeType == ExpressionType.Constant)
|
||||
if (item is ConstantExpression)
|
||||
{
|
||||
this.Expression = item;
|
||||
this.Start();
|
||||
@ -280,12 +281,6 @@ namespace SqlSugar
|
||||
parameter.Context.Result.Append(this.Context.GetAsString(asName, parameterName));
|
||||
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.CommonTempData));
|
||||
}
|
||||
else if (item is MethodCallExpression)
|
||||
{
|
||||
this.Expression = item;
|
||||
this.Start();
|
||||
parameter.Context.Result.Append(this.Context.GetAsString(asName, parameter.CommonTempData.ObjToString()));
|
||||
}
|
||||
else if (item is MemberExpression)
|
||||
{
|
||||
if (this.Context.Result.IsLockCurrentParameter == false)
|
||||
@ -397,6 +392,12 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item is MethodCallExpression|| item is UnaryExpression)
|
||||
{
|
||||
this.Expression = item;
|
||||
this.Start();
|
||||
parameter.Context.Result.Append(this.Context.GetAsString(asName, parameter.CommonTempData.ObjToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Check.ThrowNotSupportedException(item.GetType().Name);
|
||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("4.2.1.9")]
|
||||
[assembly: AssemblyFileVersion("4.2.1.9")]
|
||||
[assembly: AssemblyVersion("4.2.2")]
|
||||
[assembly: AssemblyFileVersion("4.2.2")]
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user