Join and UpdateColumns BUG

https://github.com/sunkaixuan/SqlSugar/issues/121
This commit is contained in:
sunkaixuan
2018-11-10 13:59:53 +08:00
parent 33f843a733
commit 8100454b81
5 changed files with 33 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
using OrmTest.Demo; using OrmTest.Demo;
using OrmTest.Models;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -47,6 +48,20 @@ SqlFunc.Contains(u.BuildName, keyword) || SqlFunc.IsNullOrEmpty(keyword)))
RoomID = SqlFunc.AggregateMax(ru.RoomID), 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) 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(); }).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 public class MainTable
{ {

View File

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

View File

@@ -124,7 +124,7 @@ namespace SqlSugar
{ {
base.Expression = item; base.Expression = item;
base.Start(); 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)));
} }
} }

View File

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

View File

@@ -13,6 +13,7 @@ namespace SqlSugar
internal const char SpaceChar =' '; internal const char SpaceChar =' ';
internal const string AssemblyName = "SqlSugar"; internal const string AssemblyName = "SqlSugar";
internal const string ReplaceKey = "{662E689B-17A1-4D06-9D27-F29EAB8BC3D6}"; 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 IntType = typeof(int);
internal static Type LongType = typeof(long); internal static Type LongType = typeof(long);