Synchronization code

This commit is contained in:
sunkaixuan 2023-03-19 17:39:06 +08:00
parent 55a2ff644e
commit 4f88aae62e
4 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SqlSugar
{
internal class SubQueryToListDefaultT
{
public int id { get; set; }
public object sugarIndex { get; set; }
}
}

View File

@ -1778,6 +1778,12 @@ namespace SqlSugar
isFirst = true; isFirst = true;
} }
var sqlstring = string.Join(" \r\n UNION ALL ", sqls); var sqlstring = string.Join(" \r\n UNION ALL ", sqls);
if (callType?.IsClass() == false)
{
Regex regex = new Regex(@"\,\d{1,10} as sugarIndex");
sqlstring = regex.Replace(sqlstring, it=> (" as id " + it.Value));
callType = typeof(SubQueryToListDefaultT);
}
var methodParamters = new object[] { sqlstring, ps.ToArray() }; var methodParamters = new object[] { sqlstring, ps.ToArray() };
this.QueryBuilder.SubToListParameters = null; this.QueryBuilder.SubToListParameters = null;
this.QueryBuilder.AppendColumns = new List<QueryableAppendColumn>() { this.QueryBuilder.AppendColumns = new List<QueryableAppendColumn>() {
@ -1818,6 +1824,10 @@ namespace SqlSugar
if (appValue[0].Value.ObjToInt() == i) if (appValue[0].Value.ObjToInt() == i)
{ {
var addItem = list[appindex]; var addItem = list[appindex];
if (addItem is SubQueryToListDefaultT)
{
addItem = (addItem as SubQueryToListDefaultT).id;
}
setValue.Add(addItem); setValue.Add(addItem);
} }
appindex++; appindex++;
@ -1899,6 +1909,10 @@ namespace SqlSugar
if (appValue[0].Value.ObjToInt() == resIndex) if (appValue[0].Value.ObjToInt() == resIndex)
{ {
var addItem = list[appindex]; var addItem = list[appindex];
if (addItem is SubQueryToListDefaultT)
{
addItem= ((SubQueryToListDefaultT)addItem).id;
}
setValue.Add(addItem); setValue.Add(addItem);
} }
appindex++; appindex++;

View File

@ -176,7 +176,7 @@ namespace SqlSugar
return new List<T>(); return new List<T>();
} }
public List<TResult> ToList<TResult>(Func<T, TResult> selector) where TResult:class,new() public List<TResult> ToList<TResult>(Func<T, TResult> selector)
{ {
return null; return null;
} }

View File

@ -119,6 +119,7 @@
<Compile Include="Abstract\InsertableProvider\InsertMethodInfo.cs" /> <Compile Include="Abstract\InsertableProvider\InsertMethodInfo.cs" />
<Compile Include="Abstract\QueryableProvider\Entities\QueryableAppendColumn.cs" /> <Compile Include="Abstract\QueryableProvider\Entities\QueryableAppendColumn.cs" />
<Compile Include="Abstract\QueryableProvider\Entities\SqlInfo.cs" /> <Compile Include="Abstract\QueryableProvider\Entities\SqlInfo.cs" />
<Compile Include="Abstract\QueryableProvider\Entities\SubQueryToListDefaultT.cs" />
<Compile Include="Abstract\QueryableProvider\QueryableExecuteSqlAsync.cs" /> <Compile Include="Abstract\QueryableProvider\QueryableExecuteSqlAsync.cs" />
<Compile Include="Abstract\QueryableProvider\QueryableExecuteSql.cs" /> <Compile Include="Abstract\QueryableProvider\QueryableExecuteSql.cs" />
<Compile Include="Abstract\QueryableProvider\QueryableProperties.cs" /> <Compile Include="Abstract\QueryableProvider\QueryableProperties.cs" />