sunkaixuan 6 years ago
parent
commit
8100454b81
  1. 15
      Src/Asp.Net/SqlServerTest/BugTest/Bug1.cs
  2. 19
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionResult.cs
  3. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs
  4. 4
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/NewArrayExpessionResolve.cs
  5. 1
      Src/Asp.Net/SqlSugar/Utilities/UtilConstants.cs

15
Src/Asp.Net/SqlServerTest/BugTest/Bug1.cs

@ -1,4 +1,5 @@
using OrmTest.Demo;
using OrmTest.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
@ -47,6 +48,20 @@ SqlFunc.Contains(u.BuildName, keyword) || SqlFunc.IsNullOrEmpty(keyword)))
RoomID = SqlFunc.AggregateMax(ru.RoomID),
Owner = SqlFunc.Subqueryable<SubTable>().Where(r => r.RoomID == ru.RoomID && SqlFunc.Equals(r.RoomUserType, "业主") && SqlFunc.Equals(r.RoomUserType, "业主")).Select(s => s.RoomerName)
}).OrderBy((r) => r.RoomNumber, type: OrderByType.Desc).ToPageListAsync(1, 2).Wait();
GetInstance().Updateable<Student>().UpdateColumns(it =>
new Student() {
Name = "a".ToString(),
CreateTime=DateTime.Now.AddDays(-1)
}
).Where(it=>it.Id==1).ExecuteCommand();
var list = GetInstance().Queryable<Student, School>((st, sc) => new object[] {
JoinType.Left,st.SchoolId==sc.Id&&st.CreateTime==DateTime.Now.AddDays(-1)
})
.Where(st => st.Name == "jack").ToList();
}
public class MainTable
{

19
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionResult.cs

@ -63,19 +63,28 @@ namespace SqlSugar
{
if (_Result == null) return null;
if (IsUpper)
return _Result.ToString().ToUpper().TrimEnd(',');
return _Result.ToString().ToUpper().Replace(UtilConstants.ReplaceCommaKey,",").TrimEnd(',');
else
return _Result.ToString().TrimEnd(',');
return _Result.ToString().Replace(UtilConstants.ReplaceCommaKey, ",").TrimEnd(',');
}
#region functions
public string[] GetResultArray()
{
if (this._Result == null) return null;
var reslut = new List<string>();
if (IsUpper)
reslut= this.Result.ToString().ToUpper().TrimEnd(',').Split(',').ToList();
else
reslut= this.Result.ToString().TrimEnd(',').Split(',').ToList();
if (this.Result.ToString().Contains(UtilConstants.ReplaceCommaKey))
{
for (int i = 0; i < reslut.Count; i++)
{
reslut[i] = reslut[i].Replace(UtilConstants.ReplaceCommaKey, ",");
}
}
return reslut.ToArray();
}
@ -84,12 +93,12 @@ namespace SqlSugar
if (this._Result == null) return null;
if (this._ResolveExpressType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle))
{
return this.Result.ToString().TrimEnd(',');
return this.Result.ToString().Replace(UtilConstants.ReplaceCommaKey, ",").TrimEnd(',');
}
if (IsUpper)
return this.Result.ToString().ToUpper();
return this.Result.ToString().Replace(UtilConstants.ReplaceCommaKey, ",").ToUpper();
else
return this.Result.ToString();
return this.Result.ToString().Replace(UtilConstants.ReplaceCommaKey, ",");
}
public void TrimEnd()

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs

@ -124,7 +124,7 @@ namespace SqlSugar
{
base.Expression = item;
base.Start();
parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameter.CommonTempData.ObjToString()));
parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameter.CommonTempData.ObjToString().Replace(",", UtilConstants.ReplaceCommaKey)));
}
}

4
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/NewArrayExpessionResolve.cs

@ -42,11 +42,11 @@ namespace SqlSugar
{
if (i > 0)
{
base.Context.Result.Append("," + parameter.CommonTempData.ObjToString() + ",");
base.Context.Result.Append("," + parameter.CommonTempData.ObjToString().Replace(",",UtilConstants.ReplaceCommaKey) + ",");
}
else
{
base.Context.Result.Append(parameter.CommonTempData.ObjToString() + ",");
base.Context.Result.Append(parameter.CommonTempData.ObjToString().Replace(",", UtilConstants.ReplaceCommaKey) + ",");
}
++i;
}

1
Src/Asp.Net/SqlSugar/Utilities/UtilConstants.cs

@ -13,6 +13,7 @@ namespace SqlSugar
internal const char SpaceChar =' ';
internal const string AssemblyName = "SqlSugar";
internal const string ReplaceKey = "{662E689B-17A1-4D06-9D27-F29EAB8BC3D6}";
internal const string ReplaceCommaKey = "{112A689B-17A1-4A06-9D27-A39EAB8BC3D5}";
internal static Type IntType = typeof(int);
internal static Type LongType = typeof(long);

Loading…
Cancel
Save