mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
Merge branch 'master' of github.com:dotnetcore/FreeSql
This commit is contained in:
commit
fdacbf26e3
@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>3.2.666-preview20220606</Version>
|
||||
<Version>3.2.662</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -70,7 +70,7 @@ public static class FreeSqlExtensionsLinqSql
|
||||
internal static void InternalJoin2<T1>(Select1Provider<T1> s1p, LambdaExpression outerKeySelector, LambdaExpression innerKeySelector, LambdaExpression resultSelector) where T1 : class
|
||||
{
|
||||
s1p._tables[0].Parameter = resultSelector.Parameters[0];
|
||||
s1p._commonExpression.ExpressionLambdaToSql(outerKeySelector, new CommonExpression.ExpTSC { _tables = s1p._tables });
|
||||
s1p._commonExpression.ExpressionLambdaToSql(outerKeySelector, new CommonExpression.ExpTSC { _tables = s1p._tables, _tableRule = s1p._tableRule });
|
||||
s1p.InternalJoin(Expression.Lambda(typeof(Func<,,>).MakeGenericType(typeof(T1), innerKeySelector.Parameters[0].Type, typeof(bool)),
|
||||
Expression.Equal(outerKeySelector.Body, innerKeySelector.Body),
|
||||
new[] { outerKeySelector.Parameters[0], innerKeySelector.Parameters[0] }
|
||||
|
@ -67,7 +67,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var index = -10000; //临时规则,不返回 as1
|
||||
|
||||
if (selector != null)
|
||||
_comonExp.ReadAnonymousField(_select._tables, field, _map, ref index, selector, null, null, _select._whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
_comonExp.ReadAnonymousField(_select._tables, _select._tableRule, field, _map, ref index, selector, null, null, _select._whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
_field = field.ToString();
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (condition == false) return this;
|
||||
_lambdaParameter = column?.Parameters[0];
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, column, this, null, null);
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, null, column, this, null, null);
|
||||
var method = _select.GetType().GetMethod("OrderBy", new[] { typeof(string), typeof(object) });
|
||||
method.Invoke(_select, new object[] { descending ? $"{sql} DESC" : sql, null });
|
||||
return this;
|
||||
@ -174,7 +174,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (condition == false) return this;
|
||||
_lambdaParameter = exp?.Parameters[0];
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, exp, this, null, null);
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, null, exp, this, null, null);
|
||||
var method = _select.GetType().GetMethod("Where", new[] { typeof(string), typeof(object) });
|
||||
method.Invoke(_select, new object[] { sql, null });
|
||||
return this;
|
||||
|
@ -728,15 +728,6 @@
|
||||
<param name="modelBuilder"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSqlDbContextExtensions.ApplyConfigurationsFromAssembly(FreeSql.ICodeFirst,System.Reflection.Assembly,System.Func{System.Type,System.Boolean})">
|
||||
<summary>
|
||||
根据Assembly扫描所有继承IEntityTypeConfiguration<T>的配置类
|
||||
</summary>
|
||||
<param name="codeFirst"></param>
|
||||
<param name="assembly"></param>
|
||||
<param name="predicate"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSqlDbContextExtensions.CreateDbContext(IFreeSql)">
|
||||
<summary>
|
||||
创建普通数据上下文档对象
|
||||
|
@ -12,26 +12,6 @@ namespace FreeSql.Tests.Odbc.Default
|
||||
public class OdbcCodeFirstTest
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void Test_0String()
|
||||
{
|
||||
var fsql = g.odbc;
|
||||
fsql.Delete<test_0string01>().Where("1=1").ExecuteAffrows();
|
||||
|
||||
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).ExecuteAffrows());
|
||||
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).NoneParameter().ExecuteAffrows());
|
||||
|
||||
var list = fsql.Select<test_0string01>().ToList();
|
||||
Assert.Equal(2, list.Count);
|
||||
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[0].name);
|
||||
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[1].name);
|
||||
}
|
||||
class test_0string01
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void 中文表_字段()
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -83,6 +83,13 @@ namespace FreeSql.Tests.SqlServerExpression
|
||||
IEnumerable<int> testlinqlist = new List<int>(new[] { 1, 2, 3 });
|
||||
var testlinq = select.Where(a => testlinqlist.Contains(a.testFieldInt)).ToList();
|
||||
|
||||
var testlinqlist2 = new List<TableAllType>(new[] {
|
||||
new TableAllType{Id = 1,},
|
||||
new TableAllType{Id = 2,},
|
||||
new TableAllType{Id = 3,}
|
||||
}).Select(a => a.Id).ToArray().Distinct();
|
||||
var testlinq2 = select.Where(a => testlinqlist2.Contains(a.testFieldInt) && a.testFieldByte == 1).ToList();
|
||||
|
||||
//in not in
|
||||
var sql111 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt)).ToList();
|
||||
var sql112 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt) == false).ToList();
|
||||
|
@ -1126,6 +1126,24 @@ WHERE (((cast(a.""Id"" as character)) in (SELECT b.""Title""
|
||||
[Fact]
|
||||
public void AsTable()
|
||||
{
|
||||
var fsql = g.sqlite;
|
||||
var asTableSubSql = fsql.Select<TestTypeParentInfo>().AsTable((_, old) => $"{old}_01").ToSql(a => new
|
||||
{
|
||||
a.Id,
|
||||
max = fsql.Select<TestTypeInfo>().Max(b => b.Guid),
|
||||
any = a.Types.Any(b => b.Name == "xx"),
|
||||
any2 = a.Types.AsSelect().Any(b => b.Name == "xx"),
|
||||
sub = fsql.Select<TestTypeInfo>().Where(b => b.Guid == a.Id).ToList()
|
||||
});
|
||||
Assert.Equal(@"SELECT a.""Id"" as1, ifnull((SELECT max(a.""Guid"")
|
||||
FROM ""TestTypeInfo_01"" a), 0) as2, exists(SELECT 1
|
||||
FROM ""TestTypeInfo_01"" b
|
||||
WHERE (b.""ParentId"" = a.""Id"") AND (b.""Name"" = 'xx')
|
||||
limit 0,1) as3, exists(SELECT 1
|
||||
FROM ""TestTypeInfo_01"" b
|
||||
WHERE (b.""Name"" = 'xx') AND (b.""ParentId"" = a.""Id"")
|
||||
limit 0,1) as4
|
||||
FROM ""TestTypeParentInfo_01"" a", asTableSubSql);
|
||||
|
||||
var listt = select.AsTable((a, b) => "(select * from tb_topic where clicks > 10)").Page(1, 10).ToList();
|
||||
|
||||
|
@ -696,10 +696,10 @@ JOIN {select._commonUtils.QuoteSqlName(tb.DbName)} a ON cte_tbc.cte_id = a.{sele
|
||||
case DataType.OdbcSqlServer:
|
||||
case DataType.Firebird:
|
||||
case DataType.ClickHouse:
|
||||
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, Expression.Call(typeof(Convert).GetMethod("ToString", new Type[] { typeof(string) }), pathSelector?.Body), null, null, null);
|
||||
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, Expression.Call(typeof(Convert).GetMethod("ToString", new Type[] { typeof(string) }), pathSelector?.Body), null, null, null);
|
||||
break;
|
||||
default:
|
||||
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, pathSelector?.Body, null, null, null);
|
||||
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, null, null, null);
|
||||
break;
|
||||
}
|
||||
sql1ctePath = $"{sql1ctePath} as cte_path, ";
|
||||
@ -717,7 +717,7 @@ JOIN {select._commonUtils.QuoteSqlName(tb.DbName)} a ON cte_tbc.cte_id = a.{sele
|
||||
if (pathSelector != null)
|
||||
{
|
||||
select._tables[0].Parameter = pathSelector?.Parameters[0];
|
||||
var wct2ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, pathSelector?.Body, null, null, null);
|
||||
var wct2ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, null, null, null);
|
||||
sql2ctePath = select._commonUtils.StringConcat(
|
||||
new string[] {
|
||||
up == false ? "wct1.cte_path" : wct2ctePath,
|
||||
|
@ -37,6 +37,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Internal\CommonProvider\SelectProvider\Select1Provider2`16.cs">
|
||||
<DependentUpon>Select1Provider2`16.tt</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
</Compile>
|
||||
<Compile Update="Properties\CoreStrings.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
@ -45,6 +50,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Internal\CommonProvider\SelectProvider\T4Temp\Select1Provider2`16.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Select1Provider2`16.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Properties\CoreStrings.Designer.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>CoreStrings.Designer.cs</LastGenOutput>
|
||||
|
@ -47,14 +47,14 @@ namespace FreeSql.Internal
|
||||
if (_common.CodeFirst.IsSyncStructureToUpper) csname = csname.ToUpper();
|
||||
return csname;
|
||||
}
|
||||
public bool ReadAnonymousField(List<SelectTableInfo> _tables, StringBuilder field, ReadAnonymousTypeInfo parent, ref int index, Expression exp, Select0Provider select,
|
||||
public bool ReadAnonymousField(List<SelectTableInfo> _tables, Func<Type, string, string> _tableRule, StringBuilder field, ReadAnonymousTypeInfo parent, ref int index, Expression exp, Select0Provider select,
|
||||
BaseDiyMemberExpression diymemexp, List<GlobalFilter.Item> whereGlobalFilter, List<string> findIncludeMany, List<Expression> findSubSelectMany, bool isAllDtoMap)
|
||||
{
|
||||
Func<ExpTSC> getTSC = () => new ExpTSC { _tables = _tables, diymemexp = diymemexp, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereGlobalFilter = whereGlobalFilter, dbParams = select?._params }; //#462 添加 DbParams 解决
|
||||
Func<ExpTSC> getTSC = () => new ExpTSC { _tables = _tables, _tableRule = _tableRule, diymemexp = diymemexp, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereGlobalFilter = whereGlobalFilter, dbParams = select?._params }; //#462 添加 DbParams 解决
|
||||
switch (exp.NodeType)
|
||||
{
|
||||
case ExpressionType.Quote: return ReadAnonymousField(_tables, field, parent, ref index, (exp as UnaryExpression)?.Operand, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
case ExpressionType.Lambda: return ReadAnonymousField(_tables, field, parent, ref index, (exp as LambdaExpression)?.Body, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
case ExpressionType.Quote: return ReadAnonymousField(_tables, _tableRule, field, parent, ref index, (exp as UnaryExpression)?.Operand, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
case ExpressionType.Lambda: return ReadAnonymousField(_tables, _tableRule, field, parent, ref index, (exp as LambdaExpression)?.Body, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
case ExpressionType.Negate:
|
||||
case ExpressionType.NegateChecked:
|
||||
parent.DbField = $"-({ExpressionLambdaToSql(exp, getTSC())})";
|
||||
@ -63,7 +63,7 @@ namespace FreeSql.Internal
|
||||
else if (index == ReadAnonymousFieldAsCsName && string.IsNullOrEmpty(parent.CsName) == false) field.Append(_common.FieldAsAlias(GetFieldAsCsName(parent.CsName)));
|
||||
if (parent.CsType == null && exp.Type.IsValueType) parent.CsType = exp.Type;
|
||||
return false;
|
||||
case ExpressionType.Convert: return ReadAnonymousField(_tables, field, parent, ref index, (exp as UnaryExpression)?.Operand, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
case ExpressionType.Convert: return ReadAnonymousField(_tables, _tableRule, field, parent, ref index, (exp as UnaryExpression)?.Operand, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
case ExpressionType.Constant:
|
||||
var constExp = exp as ConstantExpression;
|
||||
//处理自定义SQL语句,如: ToList(new {
|
||||
@ -85,7 +85,7 @@ namespace FreeSql.Internal
|
||||
return false;
|
||||
case ExpressionType.Conditional:
|
||||
var condExp = exp as ConditionalExpression;
|
||||
if (condExp.Test.IsParameter() == false) return ReadAnonymousField(_tables, field, parent, ref index,
|
||||
if (condExp.Test.IsParameter() == false) return ReadAnonymousField(_tables, _tableRule, field, parent, ref index,
|
||||
(bool)Expression.Lambda(condExp.Test).Compile().DynamicInvoke() ? condExp.IfTrue : condExp.IfFalse, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
break;
|
||||
case ExpressionType.Call:
|
||||
@ -125,7 +125,7 @@ namespace FreeSql.Internal
|
||||
{
|
||||
//加载表所有字段
|
||||
var map = new List<SelectColumnInfo>();
|
||||
ExpressionSelectColumn_MemberAccess(_tables, map, SelectTableInfoType.From, exp, true, diymemexp);
|
||||
ExpressionSelectColumn_MemberAccess(_tables, _tableRule, map, SelectTableInfoType.From, exp, true, diymemexp);
|
||||
var tb = parent.Table = map.First().Table.Table;
|
||||
parent.CsType = tb.Type;
|
||||
parent.Consturctor = tb.Type.InternalGetTypeConstructor0OrFirst();
|
||||
@ -167,7 +167,7 @@ namespace FreeSql.Internal
|
||||
MapType = memProp.PropertyType
|
||||
};
|
||||
parent.Childs.Add(child);
|
||||
ReadAnonymousField(_tables, field, child, ref index, Expression.MakeMemberAccess(exp, memProp), select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, Expression.MakeMemberAccess(exp, memProp), select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,7 +251,7 @@ namespace FreeSql.Internal
|
||||
MapType = initExp.NewExpression.Arguments[a].Type
|
||||
};
|
||||
parent.Childs.Add(child);
|
||||
ReadAnonymousField(_tables, field, child, ref index, initExp.NewExpression.Arguments[a], select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, initExp.NewExpression.Arguments[a], select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
}
|
||||
}
|
||||
else if (isAllDtoMap && _tables != null && _tables.Any() && initExp.NewExpression.Type != _tables.FirstOrDefault().Table.Type)
|
||||
@ -276,7 +276,7 @@ namespace FreeSql.Internal
|
||||
};
|
||||
parent.Childs.Add(child);
|
||||
if (dtTb.Parameter != null)
|
||||
ReadAnonymousField(_tables, field, child, ref index, Expression.Property(dtTb.Parameter, dtTb.Table.Properties[trydtocol.CsName]), select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, Expression.Property(dtTb.Parameter, dtTb.Table.Properties[trydtocol.CsName]), select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
else
|
||||
{
|
||||
child.DbField = $"{dtTb.Alias}.{_common.QuoteSqlName(trydtocol.Attribute.Name)}";
|
||||
@ -303,7 +303,7 @@ namespace FreeSql.Internal
|
||||
};
|
||||
if (child.Property == null) child.ReflectionField = initExp.Type.GetField(initExp.Bindings[a].Member.Name, BindingFlags.Public | BindingFlags.Instance);
|
||||
parent.Childs.Add(child);
|
||||
ReadAnonymousField(_tables, field, child, ref index, initAssignExp.Expression, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, initAssignExp.Expression, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
}
|
||||
}
|
||||
if (parent.Childs.Any() == false) throw new Exception(CoreStrings.Mapping_Exception_HasNo_SamePropertyName(initExp.NewExpression.Type.Name));
|
||||
@ -336,7 +336,7 @@ namespace FreeSql.Internal
|
||||
MapType = newExp.Arguments[a].Type
|
||||
};
|
||||
parent.Childs.Add(child);
|
||||
ReadAnonymousField(_tables, field, child, ref index, newExp.Arguments[a], select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, newExp.Arguments[a], select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -360,7 +360,7 @@ namespace FreeSql.Internal
|
||||
};
|
||||
parent.Childs.Add(child);
|
||||
if (dtTb.Parameter != null)
|
||||
ReadAnonymousField(_tables, field, child, ref index, Expression.Property(dtTb.Parameter, dtTb.Table.Properties[trydtocol.CsName]), select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, Expression.Property(dtTb.Parameter, dtTb.Table.Properties[trydtocol.CsName]), select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, isAllDtoMap);
|
||||
else
|
||||
{
|
||||
child.DbField = _common.RereadColumn(trydtocol, $"{dtTb.Alias}.{_common.QuoteSqlName(trydtocol.Attribute.Name)}");
|
||||
@ -472,32 +472,32 @@ namespace FreeSql.Internal
|
||||
return null;
|
||||
}
|
||||
|
||||
public string ExpressionSelectColumn_MemberAccess(List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, SelectTableInfoType tbtype, Expression exp, bool isQuoteName, BaseDiyMemberExpression diymemexp)
|
||||
public string ExpressionSelectColumn_MemberAccess(List<SelectTableInfo> _tables, Func<Type, string, string> _tableRule, List<SelectColumnInfo> _selectColumnMap, SelectTableInfoType tbtype, Expression exp, bool isQuoteName, BaseDiyMemberExpression diymemexp)
|
||||
{
|
||||
return ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _selectColumnMap = _selectColumnMap, diymemexp = diymemexp, tbtype = tbtype, isQuoteName = isQuoteName, isDisableDiyParse = false, style = ExpressionStyle.SelectColumns });
|
||||
return ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _tableRule = _tableRule, _selectColumnMap = _selectColumnMap, diymemexp = diymemexp, tbtype = tbtype, isQuoteName = isQuoteName, isDisableDiyParse = false, style = ExpressionStyle.SelectColumns });
|
||||
}
|
||||
|
||||
public string[] ExpressionSelectColumns_MemberAccess_New_NewArrayInit(List<SelectTableInfo> _tables, Expression exp, bool isQuoteName, BaseDiyMemberExpression diymemexp)
|
||||
public string[] ExpressionSelectColumns_MemberAccess_New_NewArrayInit(List<SelectTableInfo> _tables, Func<Type, string, string> _tableRule, Expression exp, bool isQuoteName, BaseDiyMemberExpression diymemexp)
|
||||
{
|
||||
switch (exp?.NodeType)
|
||||
{
|
||||
case ExpressionType.Quote: return ExpressionSelectColumns_MemberAccess_New_NewArrayInit(_tables, (exp as UnaryExpression)?.Operand, isQuoteName, diymemexp);
|
||||
case ExpressionType.Lambda: return ExpressionSelectColumns_MemberAccess_New_NewArrayInit(_tables, (exp as LambdaExpression)?.Body, isQuoteName, diymemexp);
|
||||
case ExpressionType.Convert: return ExpressionSelectColumns_MemberAccess_New_NewArrayInit(_tables, (exp as UnaryExpression)?.Operand, isQuoteName, diymemexp);
|
||||
case ExpressionType.Constant: return new[] { ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, isQuoteName, diymemexp) };
|
||||
case ExpressionType.Quote: return ExpressionSelectColumns_MemberAccess_New_NewArrayInit(_tables, _tableRule, (exp as UnaryExpression)?.Operand, isQuoteName, diymemexp);
|
||||
case ExpressionType.Lambda: return ExpressionSelectColumns_MemberAccess_New_NewArrayInit(_tables, _tableRule, (exp as LambdaExpression)?.Body, isQuoteName, diymemexp);
|
||||
case ExpressionType.Convert: return ExpressionSelectColumns_MemberAccess_New_NewArrayInit(_tables, _tableRule, (exp as UnaryExpression)?.Operand, isQuoteName, diymemexp);
|
||||
case ExpressionType.Constant: return new[] { ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, isQuoteName, diymemexp) };
|
||||
case ExpressionType.Call:
|
||||
case ExpressionType.MemberAccess: return ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, isQuoteName, diymemexp).Trim('(', ')', '\'').Split(new[] { "','" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
case ExpressionType.MemberAccess: return ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, isQuoteName, diymemexp).Trim('(', ')', '\'').Split(new[] { "','" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
case ExpressionType.New:
|
||||
var newExp = exp as NewExpression;
|
||||
if (newExp == null) break;
|
||||
var newExpMembers = new string[newExp.Members.Count];
|
||||
for (var a = 0; a < newExpMembers.Length; a++) newExpMembers[a] = ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, newExp.Arguments[a], isQuoteName, diymemexp);
|
||||
for (var a = 0; a < newExpMembers.Length; a++) newExpMembers[a] = ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, newExp.Arguments[a], isQuoteName, diymemexp);
|
||||
return newExpMembers.Distinct().Select(a => a.Trim('\'')).ToArray();
|
||||
case ExpressionType.NewArrayInit:
|
||||
var newArr = exp as NewArrayExpression;
|
||||
if (newArr == null) break;
|
||||
var newArrMembers = new List<string>();
|
||||
foreach (var newArrExp in newArr.Expressions) newArrMembers.AddRange(ExpressionSelectColumns_MemberAccess_New_NewArrayInit(_tables, newArrExp, isQuoteName, diymemexp));
|
||||
foreach (var newArrExp in newArr.Expressions) newArrMembers.AddRange(ExpressionSelectColumns_MemberAccess_New_NewArrayInit(_tables, _tableRule, newArrExp, isQuoteName, diymemexp));
|
||||
return newArrMembers.Distinct().Select(a => a.Trim('\'')).ToArray();
|
||||
default: throw new ArgumentException(CoreStrings.Unable_Parse_Expression(exp));
|
||||
}
|
||||
@ -522,22 +522,22 @@ namespace FreeSql.Internal
|
||||
{ ExpressionType.Equal, "=" },
|
||||
};
|
||||
|
||||
public string ExpressionWhereLambdaNoneForeignObject(List<SelectTableInfo> _tables, TableInfo table, List<SelectColumnInfo> _selectColumnMap, Expression exp, BaseDiyMemberExpression diymemexp, List<DbParameter> dbParams)
|
||||
public string ExpressionWhereLambdaNoneForeignObject(List<SelectTableInfo> _tables, Func<Type, string, string> _tableRule, TableInfo table, List<SelectColumnInfo> _selectColumnMap, Expression exp, BaseDiyMemberExpression diymemexp, List<DbParameter> dbParams)
|
||||
{
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _selectColumnMap = _selectColumnMap, diymemexp = diymemexp, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, currentTable = table, dbParams = dbParams });
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _tableRule = _tableRule, _selectColumnMap = _selectColumnMap, diymemexp = diymemexp, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, currentTable = table, dbParams = dbParams });
|
||||
return GetBoolString(exp, sql);
|
||||
}
|
||||
|
||||
public string ExpressionWhereLambda(List<SelectTableInfo> _tables, Expression exp, BaseDiyMemberExpression diymemexp, List<GlobalFilter.Item> whereGlobalFilter, List<DbParameter> dbParams)
|
||||
public string ExpressionWhereLambda(List<SelectTableInfo> _tables, Func<Type, string, string> _tableRule, Expression exp, BaseDiyMemberExpression diymemexp, List<GlobalFilter.Item> whereGlobalFilter, List<DbParameter> dbParams)
|
||||
{
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, diymemexp = diymemexp, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereGlobalFilter = whereGlobalFilter, dbParams = dbParams });
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _tableRule = _tableRule, diymemexp = diymemexp, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereGlobalFilter = whereGlobalFilter, dbParams = dbParams });
|
||||
return GetBoolString(exp, sql);
|
||||
}
|
||||
static ConcurrentDictionary<string, Regex> dicRegexAlias = new ConcurrentDictionary<string, Regex>();
|
||||
public void ExpressionJoinLambda(List<SelectTableInfo> _tables, SelectTableInfoType tbtype, Expression exp, BaseDiyMemberExpression diymemexp, List<GlobalFilter.Item> whereGlobalFilter)
|
||||
public void ExpressionJoinLambda(List<SelectTableInfo> _tables, Func<Type, string, string> _tableRule, SelectTableInfoType tbtype, Expression exp, BaseDiyMemberExpression diymemexp, List<GlobalFilter.Item> whereGlobalFilter)
|
||||
{
|
||||
var tbidx = _tables.Count;
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, diymemexp = diymemexp, tbtype = tbtype, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereGlobalFilter = whereGlobalFilter });
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _tableRule = _tableRule, diymemexp = diymemexp, tbtype = tbtype, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereGlobalFilter = whereGlobalFilter });
|
||||
sql = GetBoolString(exp, sql);
|
||||
|
||||
if (_tables.Count > tbidx)
|
||||
@ -757,7 +757,7 @@ namespace FreeSql.Internal
|
||||
_common._orm.Aop.ParseExpressionHandler(this, args);
|
||||
if (string.IsNullOrEmpty(args.Result) == false) return args.Result;
|
||||
}
|
||||
ParseExpressionNoAsSelect(this, args);
|
||||
ParseExpressionNoAsSelect(this, args, tsc._tableRule);
|
||||
if (string.IsNullOrEmpty(args.Result) == false) return args.Result;
|
||||
}
|
||||
switch (exp.NodeType)
|
||||
@ -993,6 +993,7 @@ namespace FreeSql.Internal
|
||||
break;
|
||||
}
|
||||
object fsql = null;
|
||||
Select0Provider fsqlSelect0 = null;
|
||||
List<SelectTableInfo> fsqltables = null;
|
||||
var fsqltable1SetAlias = false;
|
||||
Type fsqlType = null;
|
||||
@ -1071,7 +1072,7 @@ namespace FreeSql.Internal
|
||||
if (fsql == null) fsql = Expression.Lambda(exp3tmp).Compile().DynamicInvoke();
|
||||
fsqlType = fsql?.GetType();
|
||||
if (fsqlType == null) break;
|
||||
var fsqlSelect0 = fsql as Select0Provider;
|
||||
fsqlSelect0 = fsql as Select0Provider;
|
||||
switch (exp3.Method.Name)
|
||||
{
|
||||
case "Any": //exists
|
||||
@ -1194,6 +1195,9 @@ namespace FreeSql.Internal
|
||||
}
|
||||
if (fsql != null)
|
||||
{
|
||||
if (fsqlSelect0 != null && tsc._tableRule != null && fsqlSelect0._tableRules.Any() == false)
|
||||
fsqlSelect0._tableRules.Add(tsc._tableRule);
|
||||
|
||||
if (asSelectParentExp != null)
|
||||
{
|
||||
//执行 AsSelect() 的关联,OneToMany,ManyToMany,PgArrayToMany
|
||||
@ -1343,7 +1347,7 @@ namespace FreeSql.Internal
|
||||
var index = -1;
|
||||
|
||||
for (var a = 0; a < exp3Args0.Parameters.Count; a++) fsqls0p._tables[a].Parameter = exp3Args0.Parameters[a];
|
||||
ReadAnonymousField(fsqls0p._tables, field, map, ref index, exp3Args0, null, null, null, null, null, false);
|
||||
ReadAnonymousField(fsqls0p._tables, fsqls0p._tableRule, field, map, ref index, exp3Args0, null, null, null, null, null, false);
|
||||
var fieldSql = field.Length > 0 ? field.Remove(0, 2).ToString() : null;
|
||||
|
||||
var sql4 = fsqlType.GetMethod("ToSql", new Type[] { typeof(string) })?.Invoke(fsql, new object[] { $"{exp3.Method.Name.ToLower()}({fieldSql})" })?.ToString();
|
||||
@ -1897,6 +1901,7 @@ namespace FreeSql.Internal
|
||||
public class ExpTSC
|
||||
{
|
||||
public List<SelectTableInfo> _tables { get; set; }
|
||||
public Func<Type, string, string> _tableRule { get; set; }
|
||||
public List<SelectColumnInfo> _selectColumnMap { get; set; }
|
||||
public BaseDiyMemberExpression diymemexp { get; set; }
|
||||
public Select0Provider subSelect001 { get; set; } //#405 Oracle within group(order by ..)
|
||||
@ -1946,6 +1951,7 @@ namespace FreeSql.Internal
|
||||
return new ExpTSC
|
||||
{
|
||||
_tables = this._tables,
|
||||
_tableRule = this._tableRule,
|
||||
_selectColumnMap = v1,
|
||||
diymemexp = v2,
|
||||
tbtype = v3,
|
||||
@ -1966,6 +1972,7 @@ namespace FreeSql.Internal
|
||||
return new ExpTSC
|
||||
{
|
||||
_tables = this._tables,
|
||||
_tableRule = this._tableRule,
|
||||
_selectColumnMap = this._selectColumnMap,
|
||||
diymemexp = this.diymemexp,
|
||||
subSelect001 = this.subSelect001,
|
||||
@ -2011,8 +2018,7 @@ namespace FreeSql.Internal
|
||||
);
|
||||
var whereSql = ExpressionLambdaToSql(expExp.Body, new ExpTSC
|
||||
{
|
||||
_tables =
|
||||
isMultitb ? new List<SelectTableInfo>(new[] { tb }) : null,
|
||||
_tables = isMultitb ? new List<SelectTableInfo>(new[] { tb }) : null,
|
||||
_selectColumnMap = null,
|
||||
diymemexp = null,
|
||||
tbtype = SelectTableInfoType.From,
|
||||
@ -2119,7 +2125,7 @@ namespace FreeSql.Internal
|
||||
//return string.Concat(_ado.AddslashesProcessParam(obj, mapType, mapColumn));
|
||||
}
|
||||
|
||||
public static void ParseExpressionNoAsSelect(object sender, Aop.ParseExpressionEventArgs e)
|
||||
public static void ParseExpressionNoAsSelect(object sender, Aop.ParseExpressionEventArgs e, Func<Type, string, string> tableRule)
|
||||
{
|
||||
if (e.Expression.NodeType != ExpressionType.Call &&
|
||||
(e.Expression as MemberExpression)?.Member.Name != "Count") return;
|
||||
@ -2251,6 +2257,8 @@ namespace FreeSql.Internal
|
||||
Type = SelectTableInfoType.Parent,
|
||||
Parameter = a.Parameter
|
||||
}));
|
||||
if (tableRule != null)
|
||||
select._tableRules.Add(tableRule);
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
@ -2334,7 +2342,7 @@ namespace FreeSql.Internal
|
||||
var field = new StringBuilder();
|
||||
var index = -1;
|
||||
|
||||
commonExp.ReadAnonymousField(select._tables, field, map, ref index, callExp.Arguments[1], null, null, null, null, null, false);
|
||||
commonExp.ReadAnonymousField(select._tables, select._tableRule, field, map, ref index, callExp.Arguments[1], null, null, null, null, null, false);
|
||||
var fieldSql = field.Length > 0 ? field.Remove(0, 2).ToString() : null;
|
||||
|
||||
e.Result = commonExp._common.IsNull($"({select.ToSql($"{aggregateMethodName}({fieldSql})").Replace(" \r\n", " \r\n ")})", commonExp.formatSql(callExp.Method.ReturnType.CreateInstanceGetDefaultValue(), callExp.Method.ReturnType, null, null));
|
||||
|
@ -102,7 +102,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
public IDelete<T1> WhereIf(bool condition, Expression<Func<T1, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
return this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, null, _table, null, exp?.Body, null, _params));
|
||||
}
|
||||
public IDelete<T1> Where(string sql, object parms = null) => WhereIf(true, sql, parms);
|
||||
public IDelete<T1> WhereIf(bool condition, string sql, object parms = null)
|
||||
|
@ -67,7 +67,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
return this;
|
||||
}
|
||||
|
||||
public IInsertOrUpdate<T1> UpdateColumns(Expression<Func<T1, object>> columns) => UpdateColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null));
|
||||
public IInsertOrUpdate<T1> UpdateColumns(Expression<Func<T1, object>> columns) => UpdateColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null));
|
||||
public IInsertOrUpdate<T1> UpdateColumns(string[] columns)
|
||||
{
|
||||
var cols = columns.Distinct().ToDictionary(a => a);
|
||||
|
@ -514,8 +514,8 @@ namespace FreeSql.Internal.CommonProvider
|
||||
public abstract long ExecuteIdentity();
|
||||
public abstract List<T1> ExecuteInserted();
|
||||
|
||||
public IInsert<T1> IgnoreColumns(Expression<Func<T1, object>> columns) => IgnoreColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null));
|
||||
public IInsert<T1> InsertColumns(Expression<Func<T1, object>> columns) => InsertColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null));
|
||||
public IInsert<T1> IgnoreColumns(Expression<Func<T1, object>> columns) => IgnoreColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null));
|
||||
public IInsert<T1> InsertColumns(Expression<Func<T1, object>> columns) => InsertColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null));
|
||||
|
||||
public IInsert<T1> IgnoreColumns(string[] columns)
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
public List<DbParameter> _params = new List<DbParameter>();
|
||||
public List<SelectTableInfo> _tables = new List<SelectTableInfo>();
|
||||
public List<Func<Type, string, string>> _tableRules = new List<Func<Type, string, string>>();
|
||||
public Func<Type, string, string> _tableRule => _tableRules?.FirstOrDefault();
|
||||
public Func<Type, string, string> _aliasRule;
|
||||
public string _tosqlAppendContent;
|
||||
public StringBuilder _join = new StringBuilder();
|
||||
@ -151,7 +152,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var firstTb = _tables[0];
|
||||
var firstTbs = _tables.Where(a => a.AliasInit == field[0]).ToArray();
|
||||
if (firstTbs.Length == 1) firstTb = firstTbs[0];
|
||||
else
|
||||
else if (fromFirstTable == false)
|
||||
{
|
||||
firstTbs = _tables.Where(a => a.Table.Type.Name == field[0]).ToArray();
|
||||
if (firstTbs.Length == 1) firstTb = firstTbs[0];
|
||||
@ -269,7 +270,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var field = new StringBuilder();
|
||||
var index = fieldAlias == FieldAliasOptions.AsProperty ? CommonExpression.ReadAnonymousFieldAsCsName : 0;
|
||||
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, newexp, this, null, _whereGlobalFilter, null, null, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, newexp, this, null, _whereGlobalFilter, null, null, true);
|
||||
return new ReadAnonymousTypeAfInfo(map, field.Length > 0 ? field.Remove(0, 2).ToString() : null);
|
||||
}
|
||||
public string GetNestSelectSql(Expression select, string affield, Func<string, string> ToSql)
|
||||
@ -789,7 +790,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (condition == false) return this as TSelect;
|
||||
Expression exp = ConvertStringPropertyToExpression(property);
|
||||
if (exp == null) return this as TSelect;
|
||||
var field = _commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null);
|
||||
var field = _commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null);
|
||||
if (isAscending) return this.OrderBy(field);
|
||||
return this.OrderBy($"{field} DESC");
|
||||
}
|
||||
@ -923,7 +924,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
return new string[0];
|
||||
}
|
||||
|
||||
var sql = _commonExpression.ExpressionWhereLambda(_tables, exp, null, null, _params);
|
||||
var sql = _commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp, null, null, _params);
|
||||
|
||||
sb.Append(sql);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var property = properties[propIdx];
|
||||
var exp = ConvertStringPropertyToExpression(property);
|
||||
if (exp == null) throw new Exception(CoreStrings.Property_Cannot_Find(property));
|
||||
var field = _commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null);
|
||||
var field = _commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null);
|
||||
if (propIdx > 0) sbfield.Append(", ");
|
||||
sbfield.Append(field);
|
||||
//if (field != property)
|
||||
@ -751,7 +751,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
protected double InternalAvg(Expression exp)
|
||||
{
|
||||
var field = $"avg({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
var field = $"avg({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
if (_limit <= 0 && _skip <= 0)
|
||||
{
|
||||
var list = this.ToList<double>(field);
|
||||
@ -764,7 +764,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
protected TMember InternalMax<TMember>(Expression exp)
|
||||
{
|
||||
var field = $"max({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
var field = $"max({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
if (_limit <= 0 && _skip <= 0) return this.ToList<TMember>(field).Max();
|
||||
|
||||
var sql = GetNestSelectSql(exp, field, ToSql);
|
||||
@ -772,7 +772,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
protected TMember InternalMin<TMember>(Expression exp)
|
||||
{
|
||||
var field = $"min({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
var field = $"min({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
if (_limit <= 0 && _skip <= 0) return this.ToList<TMember>(field).Min();
|
||||
|
||||
var sql = GetNestSelectSql(exp, field, ToSql);
|
||||
@ -780,7 +780,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
protected decimal InternalSum(Expression exp)
|
||||
{
|
||||
var field = $"sum({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
var field = $"sum({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
if (_limit <= 0 && _skip <= 0) return this.ToList<decimal>(field).Sum();
|
||||
|
||||
var sql = GetNestSelectSql(exp, field, ToSql);
|
||||
@ -793,14 +793,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var field = new StringBuilder();
|
||||
var index = -10000; //临时规则,不返回 as1
|
||||
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, columns, null, null, _whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, columns, null, null, _whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
var sql = field.ToString();
|
||||
this.GroupBy(sql.Length > 0 ? sql.Substring(2) : null);
|
||||
return new SelectGroupingProvider<TKey, TValue>(_orm, this, map, sql, _commonExpression, _tables);
|
||||
}
|
||||
public TSelect InternalJoin(Expression exp, SelectTableInfoType joinType)
|
||||
{
|
||||
_commonExpression.ExpressionJoinLambda(_tables, joinType, exp, null, _whereGlobalFilter);
|
||||
_commonExpression.ExpressionJoinLambda(_tables, _tableRule, joinType, exp, null, _whereGlobalFilter);
|
||||
return this as TSelect;
|
||||
}
|
||||
protected TSelect InternalJoin<T2>(Expression exp, SelectTableInfoType joinType)
|
||||
@ -808,7 +808,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var tb = _commonUtils.GetTableByEntity(typeof(T2));
|
||||
if (tb == null) throw new ArgumentException(CoreStrings.T2_Type_Error);
|
||||
_tables.Add(new SelectTableInfo { Table = tb, Alias = $"IJ{_tables.Count}", On = null, Type = joinType });
|
||||
_commonExpression.ExpressionJoinLambda(_tables, joinType, exp, null, _whereGlobalFilter);
|
||||
_commonExpression.ExpressionJoinLambda(_tables, _tableRule, joinType, exp, null, _whereGlobalFilter);
|
||||
return this as TSelect;
|
||||
}
|
||||
protected TSelect InternalOrderBy(Expression column)
|
||||
@ -819,10 +819,10 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case ExpressionType.New:
|
||||
var newExp = column as NewExpression;
|
||||
if (newExp == null) break;
|
||||
for (var a = 0; a < newExp.Members.Count; a++) this.OrderBy(_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, newExp.Arguments[a], true, null));
|
||||
for (var a = 0; a < newExp.Members.Count; a++) this.OrderBy(_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, newExp.Arguments[a], true, null));
|
||||
return this as TSelect;
|
||||
}
|
||||
return this.OrderBy(_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, column, true, null));
|
||||
return this.OrderBy(_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, column, true, null));
|
||||
}
|
||||
protected TSelect InternalOrderByDescending(Expression column)
|
||||
{
|
||||
@ -832,10 +832,10 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case ExpressionType.New:
|
||||
var newExp = column as NewExpression;
|
||||
if (newExp == null) break;
|
||||
for (var a = 0; a < newExp.Members.Count; a++) this.OrderBy($"{_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, newExp.Arguments[a], true, null)} DESC");
|
||||
for (var a = 0; a < newExp.Members.Count; a++) this.OrderBy($"{_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, newExp.Arguments[a], true, null)} DESC");
|
||||
return this as TSelect;
|
||||
}
|
||||
return this.OrderBy($"{_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, column, true, null)} DESC");
|
||||
return this.OrderBy($"{_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, column, true, null)} DESC");
|
||||
}
|
||||
|
||||
public List<TReturn> InternalToList<TReturn>(Expression select)
|
||||
@ -845,7 +845,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var index = 0;
|
||||
var findSubSelectMany = new List<Expression>();
|
||||
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, select, this, null, _whereGlobalFilter, null, findSubSelectMany, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, select, this, null, _whereGlobalFilter, null, findSubSelectMany, true);
|
||||
var af = new ReadAnonymousTypeAfInfo(map, field.Length > 0 ? field.Remove(0, 2).ToString() : null);
|
||||
if (findSubSelectMany.Any() == false) return this.ToListMapReaderPrivate<TReturn>(af, new ReadAnonymousTypeOtherInfo[0]);
|
||||
|
||||
@ -862,7 +862,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
var otherMap = new ReadAnonymousTypeInfo();
|
||||
field.Clear();
|
||||
_commonExpression.ReadAnonymousField(_tables, field, otherMap, ref index, find.Item1, this, null, _whereGlobalFilter, null, null, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, otherMap, ref index, find.Item1, this, null, _whereGlobalFilter, null, null, true);
|
||||
var otherRet = new List<object>();
|
||||
var otherAf = new ReadAnonymousTypeOtherInfo(field.ToString(), otherMap, otherRet);
|
||||
afs.Add(NativeTuple.Create(find.Item1, find.Item2, otherAf));
|
||||
@ -947,7 +947,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var field = new StringBuilder();
|
||||
var index = -10000; //临时规则,不返回 as1
|
||||
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, select, null, null, _whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, select, null, null, _whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
|
||||
var childs = map.Childs;
|
||||
if (childs.Any() == false) throw new ArgumentException(CoreStrings.InsertInto_No_Property_Selected(typeof(TTargetEntity).DisplayCsharp()));
|
||||
@ -1028,7 +1028,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var field = new StringBuilder();
|
||||
var index = 0;
|
||||
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, select, null, null, _whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, select, null, null, _whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
var af = new ReadAnonymousTypeAfInfo(map, field.Length > 0 ? field.Remove(0, 2).ToString() : null);
|
||||
if (GetTableRuleUnions().Count <= 1) return this.ToListMapReader<TReturn>(af).FirstOrDefault();
|
||||
|
||||
@ -1041,7 +1041,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
}
|
||||
|
||||
public TSelect InternalWhere(Expression exp) => exp == null ? this as TSelect : this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp, null, _whereGlobalFilter, _params));
|
||||
public TSelect InternalWhere(Expression exp) => exp == null ? this as TSelect : this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp, null, _whereGlobalFilter, _params));
|
||||
|
||||
#region Async
|
||||
#if net40
|
||||
@ -1055,7 +1055,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var property = properties[propIdx];
|
||||
var exp = ConvertStringPropertyToExpression(property);
|
||||
if (exp == null) throw new Exception(CoreStrings.Property_Cannot_Find(property));
|
||||
var field = _commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null);
|
||||
var field = _commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null);
|
||||
if (propIdx > 0) sbfield.Append(", ");
|
||||
sbfield.Append(field);
|
||||
//if (field != property)
|
||||
@ -1299,7 +1299,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
async protected Task<double> InternalAvgAsync(Expression exp, CancellationToken cancellationToken)
|
||||
{
|
||||
var field = $"avg({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
var field = $"avg({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
if (_limit <= 0 && _skip <= 0)
|
||||
{
|
||||
var list = await this.ToListAsync<double>(field, cancellationToken);
|
||||
@ -1312,7 +1312,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
async protected Task<TMember> InternalMaxAsync<TMember>(Expression exp, CancellationToken cancellationToken)
|
||||
{
|
||||
var field = $"max({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
var field = $"max({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
if (_limit <= 0 && _skip <= 0) return (await this.ToListAsync<TMember>(field, cancellationToken)).Max();
|
||||
|
||||
var sql = GetNestSelectSql(exp, field, ToSql);
|
||||
@ -1320,7 +1320,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
async protected Task<TMember> InternalMinAsync<TMember>(Expression exp, CancellationToken cancellationToken)
|
||||
{
|
||||
var field = $"min({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
var field = $"min({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
if (_limit <= 0 && _skip <= 0) return (await this.ToListAsync<TMember>(field, cancellationToken)).Min();
|
||||
|
||||
var sql = GetNestSelectSql(exp, field, ToSql);
|
||||
@ -1328,7 +1328,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
async protected Task<decimal> InternalSumAsync(Expression exp, CancellationToken cancellationToken)
|
||||
{
|
||||
var field = $"sum({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
var field = $"sum({_commonExpression.ExpressionSelectColumn_MemberAccess(_tables, _tableRule, null, SelectTableInfoType.From, exp, true, null)}){_commonUtils.FieldAsAlias("as1")}";
|
||||
if (_limit <= 0 && _skip <= 0) return (await this.ToListAsync<decimal>(field, cancellationToken)).Sum();
|
||||
|
||||
var sql = GetNestSelectSql(exp, field, ToSql);
|
||||
@ -1344,7 +1344,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var index = 0;
|
||||
var findSubSelectMany = new List<Expression>();
|
||||
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, select, this, null, _whereGlobalFilter, null, findSubSelectMany, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, select, this, null, _whereGlobalFilter, null, findSubSelectMany, true);
|
||||
var af = new ReadAnonymousTypeAfInfo(map, field.Length > 0 ? field.Remove(0, 2).ToString() : null);
|
||||
if (findSubSelectMany.Any() == false) return await this.ToListMapReaderPrivateAsync<TReturn>(af, new ReadAnonymousTypeOtherInfo[0], cancellationToken);
|
||||
|
||||
@ -1361,7 +1361,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
var otherMap = new ReadAnonymousTypeInfo();
|
||||
field.Clear();
|
||||
_commonExpression.ReadAnonymousField(_tables, field, otherMap, ref index, find.Item1, this, null, _whereGlobalFilter, null, null, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, otherMap, ref index, find.Item1, this, null, _whereGlobalFilter, null, null, true);
|
||||
var otherRet = new List<object>();
|
||||
var otherAf = new ReadAnonymousTypeOtherInfo(field.ToString(), otherMap, otherRet);
|
||||
afs.Add(NativeTuple.Create(find.Item1, find.Item2, otherAf));
|
||||
@ -1521,7 +1521,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var field = new StringBuilder();
|
||||
var index = 0;
|
||||
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, select, null, null, _whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, select, null, null, _whereGlobalFilter, null, null, false); //不走 DTO 映射,不处理 IncludeMany
|
||||
var af = new ReadAnonymousTypeAfInfo(map, field.Length > 0 ? field.Remove(0, 2).ToString() : null);
|
||||
if (GetTableRuleUnions().Count <= 1) return (await this.ToListMapReaderAsync<TReturn>(af, cancellationToken)).FirstOrDefault();
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case "OrderBy":
|
||||
if (expCall.Arguments.Count == 2 && expCall.Arguments[0].Type == typeof(bool))
|
||||
{
|
||||
var ifcond = _commonExpression.ExpressionSelectColumn_MemberAccess(null, null, SelectTableInfoType.From, expCall.Arguments[0], false, null);
|
||||
var ifcond = _commonExpression.ExpressionSelectColumn_MemberAccess(null, _tableRule, null, SelectTableInfoType.From, expCall.Arguments[0], false, null);
|
||||
if (ifcond == "1" || ifcond == "'t'")
|
||||
this.InternalOrderBy(expCall.Arguments.LastOrDefault());
|
||||
break;
|
||||
@ -70,7 +70,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case "OrderByDescending":
|
||||
if (expCall.Arguments.Count == 2 && expCall.Arguments[0].Type == typeof(bool))
|
||||
{
|
||||
var ifcond = _commonExpression.ExpressionSelectColumn_MemberAccess(null, null, SelectTableInfoType.From, expCall.Arguments[0], false, null);
|
||||
var ifcond = _commonExpression.ExpressionSelectColumn_MemberAccess(null, _tableRule, null, SelectTableInfoType.From, expCall.Arguments[0], false, null);
|
||||
if (ifcond == "1" || ifcond == "'t'" || ifcond == "-1")//MsAccess -1
|
||||
this.InternalOrderByDescending(expCall.Arguments.LastOrDefault());
|
||||
break;
|
||||
@ -197,7 +197,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var map = new ReadAnonymousTypeInfo();
|
||||
var field = new StringBuilder();
|
||||
var index = 0;
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, select.Body, this, null, _whereGlobalFilter, findIncludeMany, null, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, select.Body, this, null, _whereGlobalFilter, findIncludeMany, null, true);
|
||||
var af = new ReadAnonymousTypeAfInfo(map, field.Length > 0 ? field.Remove(0, 2).ToString() : null);
|
||||
if (findIncludeMany.Any() == false) return this.ToListMapReaderPrivate<TReturn>(af, null);
|
||||
|
||||
@ -241,7 +241,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
var otherMap = new ReadAnonymousTypeInfo();
|
||||
field.Clear();
|
||||
_commonExpression.ReadAnonymousField(_tables, field, otherMap, ref index, otherNewInit, this, null, _whereGlobalFilter, null, null, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, otherMap, ref index, otherNewInit, this, null, _whereGlobalFilter, null, null, true);
|
||||
var otherRet = new List<object>();
|
||||
var otherAf = new ReadAnonymousTypeOtherInfo(field.ToString(), otherMap, otherRet);
|
||||
|
||||
@ -440,7 +440,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case TableRefType.OneToOne:
|
||||
_isIncluded = true;
|
||||
var curTb = _commonUtils.GetTableByEntity(exp.Type);
|
||||
_commonExpression.ExpressionWhereLambda(_tables, Expression.MakeMemberAccess(exp, curTb.Properties[curTb.ColumnsByCs.First().Value.CsName]), null, null, null);
|
||||
_commonExpression.ExpressionWhereLambda(_tables, _tableRule, Expression.MakeMemberAccess(exp, curTb.Properties[curTb.ColumnsByCs.First().Value.CsName]), null, null, null);
|
||||
break;
|
||||
}
|
||||
return this;
|
||||
@ -459,7 +459,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
_isIncluded = true;
|
||||
_tables[0].Parameter = navigateSelector.Parameters[0];
|
||||
_commonExpression.ExpressionWhereLambda(_tables, Expression.MakeMemberAccess(expBody, tb.Properties[tb.ColumnsByCs.First().Value.CsName]), null, null, null);
|
||||
_commonExpression.ExpressionWhereLambda(_tables, _tableRule, Expression.MakeMemberAccess(expBody, tb.Properties[tb.ColumnsByCs.First().Value.CsName]), null, null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -536,7 +536,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (tbNav == null) throw new Exception(CoreStrings.TypeError_CannotUse_IncludeMany(typeof(TNavigate).FullName));
|
||||
|
||||
if (collMem.Expression.NodeType != ExpressionType.Parameter)
|
||||
_commonExpression.ExpressionWhereLambda(_tables, Expression.MakeMemberAccess(collMem.Expression, tb.Properties[tb.ColumnsByCs.First().Value.CsName]), null, null, null);
|
||||
_commonExpression.ExpressionWhereLambda(_tables, _tableRule, Expression.MakeMemberAccess(collMem.Expression, tb.Properties[tb.ColumnsByCs.First().Value.CsName]), null, null, null);
|
||||
|
||||
TableRef tbref = null;
|
||||
var tbrefOneToManyColumns = new List<List<MemberExpression>>(); //临时 OneToMany 三个表关联,第三个表需要前两个表确定
|
||||
@ -1377,7 +1377,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var map = new ReadAnonymousTypeInfo();
|
||||
var field = new StringBuilder();
|
||||
var index = 0;
|
||||
_commonExpression.ReadAnonymousField(_tables, field, map, ref index, select.Body, this, null, _whereGlobalFilter, findIncludeMany, null, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, map, ref index, select.Body, this, null, _whereGlobalFilter, findIncludeMany, null, true);
|
||||
var af = new ReadAnonymousTypeAfInfo(map, field.Length > 0 ? field.Remove(0, 2).ToString() : null);
|
||||
if (findIncludeMany.Any() == false) return await this.ToListMapReaderPrivateAsync<TReturn>(af, null, cancellationToken);
|
||||
|
||||
@ -1410,7 +1410,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
var otherMap = new ReadAnonymousTypeInfo();
|
||||
field.Clear();
|
||||
_commonExpression.ReadAnonymousField(_tables, field, otherMap, ref index, otherNewInit, this, null, _whereGlobalFilter, null, null, true);
|
||||
_commonExpression.ReadAnonymousField(_tables, _tableRule, field, otherMap, ref index, otherNewInit, this, null, _whereGlobalFilter, null, null, true);
|
||||
var otherRet = new List<object>();
|
||||
var otherAf = new ReadAnonymousTypeOtherInfo(field.ToString(), otherMap, otherRet);
|
||||
|
||||
|
@ -171,14 +171,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2> ISelect<T1, T2>.WhereIf(bool condition, Expression<Func<T1, T2, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2>.Any(Expression<Func<T1, T2, bool>> exp)
|
||||
@ -186,7 +186,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -388,7 +388,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -625,14 +625,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3> ISelect<T1, T2, T3>.WhereIf(bool condition, Expression<Func<T1, T2, T3, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3>.Any(Expression<Func<T1, T2, T3, bool>> exp)
|
||||
@ -640,7 +640,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -842,7 +842,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -1081,14 +1081,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4>.Any(Expression<Func<T1, T2, T3, T4, bool>> exp)
|
||||
@ -1096,7 +1096,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -1298,7 +1298,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -1539,14 +1539,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5>.Any(Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
|
||||
@ -1554,7 +1554,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -1756,7 +1756,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -1999,14 +1999,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp)
|
||||
@ -2014,7 +2014,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -2216,7 +2216,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -2461,14 +2461,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp)
|
||||
@ -2476,7 +2476,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -2678,7 +2678,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -2925,14 +2925,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
|
||||
@ -2940,7 +2940,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -3142,7 +3142,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -3391,14 +3391,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
|
||||
@ -3406,7 +3406,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -3608,7 +3608,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -3859,14 +3859,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
|
||||
@ -3874,7 +3874,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -4076,7 +4076,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -4329,14 +4329,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> exp)
|
||||
@ -4344,7 +4344,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -4546,7 +4546,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -4801,14 +4801,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> exp)
|
||||
@ -4816,7 +4816,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -5018,7 +5018,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -5275,14 +5275,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, bool>> exp)
|
||||
@ -5290,7 +5290,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -5492,7 +5492,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -5751,14 +5751,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, bool>> exp)
|
||||
@ -5766,7 +5766,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -5968,7 +5968,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -6229,14 +6229,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, bool>> exp)
|
||||
@ -6244,7 +6244,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -6446,7 +6446,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -6709,14 +6709,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, bool>> exp)
|
||||
@ -6724,7 +6724,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -6926,7 +6926,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return _comonExp.ExpressionLambdaToSql(retExp, new CommonExpression.ExpTSC { _tables = _tables, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = true, style = CommonExpression.ExpressionStyle.Where });
|
||||
return _comonExp.ExpressionLambdaToSql(retExp, new CommonExpression.ExpTSC { _tables = _tables, _tableRule = _select._tableRule, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = true, style = CommonExpression.ExpressionStyle.Where });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void InternalHaving(Expression exp)
|
||||
{
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, exp, this, null, null);
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, _select._tableRule, exp, this, null, null);
|
||||
var method = _select.GetType().GetMethod("Having", new[] { typeof(string), typeof(object) });
|
||||
method.Invoke(_select, new object[] { sql, null });
|
||||
}
|
||||
@ -105,7 +105,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
InternalOrderBy(newExp.Arguments[a], isDescending);
|
||||
return;
|
||||
}
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, exp, this, null, null);
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, _select._tableRule, exp, this, null, null);
|
||||
var method = _select.GetType().GetMethod("OrderBy", new[] { typeof(string), typeof(object) });
|
||||
method.Invoke(_select, new object[] { isDescending ? $"{sql} DESC" : sql, null });
|
||||
}
|
||||
@ -115,7 +115,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var field = new StringBuilder();
|
||||
var index = 0;
|
||||
|
||||
_comonExp.ReadAnonymousField(null, field, map, ref index, select, null, this, null, null, null, false);
|
||||
_comonExp.ReadAnonymousField(null, _select._tableRule, field, map, ref index, select, null, this, null, null, null, false);
|
||||
if (map.Childs.Any() == false && map.MapType == null) map.MapType = elementType;
|
||||
var method = _select.GetType().GetMethod("ToListMrPrivate", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
method = method.MakeGenericMethod(elementType);
|
||||
@ -128,7 +128,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var field = new StringBuilder();
|
||||
var index = 0;
|
||||
|
||||
_comonExp.ReadAnonymousField(null, field, map, ref index, elementSelector, null, this, null, null, null, false);
|
||||
_comonExp.ReadAnonymousField(null, _select._tableRule, field, map, ref index, elementSelector, null, this, null, null, null, false);
|
||||
if (map.Childs.Any() == false && map.MapType == null) map.MapType = elementType;
|
||||
var method = _select.GetType().GetMethod("ToListMrPrivate", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
method = method.MakeGenericMethod(elementType);
|
||||
@ -143,7 +143,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var field = new StringBuilder();
|
||||
var index = fieldAlias == FieldAliasOptions.AsProperty ? CommonExpression.ReadAnonymousFieldAsCsName : 0;
|
||||
|
||||
_comonExp.ReadAnonymousField(null, field, map, ref index, select, null, this, null, null, null, false);
|
||||
_comonExp.ReadAnonymousField(null, _select._tableRule, field, map, ref index, select, null, this, null, null, null, false);
|
||||
var fieldSql = field.Length > 0 ? field.Remove(0, 2).ToString() : null;
|
||||
return InternalToSql(fieldSql);
|
||||
}
|
||||
@ -269,7 +269,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var index = 0;
|
||||
|
||||
_lambdaParameter = select?.Parameters[0];
|
||||
_comonExp.ReadAnonymousField(null, field, map, ref index, select, null, this, null, null, null, false);
|
||||
_comonExp.ReadAnonymousField(null, _select._tableRule, field, map, ref index, select, null, this, null, null, null, false);
|
||||
if (map.Childs.Any() == false && map.MapType == null) map.MapType = typeof(TReturn);
|
||||
var method = _select.GetType().GetMethod("ToListMrPrivateAsync", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
method = method.MakeGenericMethod(typeof(TReturn));
|
||||
@ -283,7 +283,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var index = 0;
|
||||
|
||||
_lambdaParameter = elementSelector?.Parameters[0];
|
||||
_comonExp.ReadAnonymousField(null, field, map, ref index, elementSelector, null, this, null, null, null, false);
|
||||
_comonExp.ReadAnonymousField(null, _select._tableRule, field, map, ref index, elementSelector, null, this, null, null, null, false);
|
||||
if (map.Childs.Any() == false && map.MapType == null) map.MapType = typeof(TElement);
|
||||
var method = _select.GetType().GetMethod("ToListMrPrivateAsync", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
method = method.MakeGenericMethod(typeof(TElement));
|
||||
|
@ -6,7 +6,7 @@
|
||||
<#@ output extension=".cs" #>
|
||||
|
||||
<#
|
||||
if (1 == 2)
|
||||
if (1 == 1)
|
||||
{
|
||||
#>
|
||||
using FreeSql.Internal.Model;
|
||||
@ -219,14 +219,14 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.WhereIf(bool condition, Expression<Func<<#=NewStr #>, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params));
|
||||
}
|
||||
|
||||
bool ISelect<<#=NewStr #>>.Any(Expression<Func<<#=NewStr #>, bool>> exp)
|
||||
@ -234,7 +234,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).Any();
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
@ -436,7 +436,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (exp == null) return await this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
var oldwhere = _where.ToString();
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, _tableRule, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(cancellationToken);
|
||||
_where.Clear().Append(oldwhere);
|
||||
return ret;
|
||||
}
|
||||
|
@ -377,8 +377,8 @@ namespace FreeSql.Internal.CommonProvider
|
||||
public abstract int ExecuteAffrows();
|
||||
public abstract List<T1> ExecuteUpdated();
|
||||
|
||||
public IUpdate<T1> IgnoreColumns(Expression<Func<T1, object>> columns) => IgnoreColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null));
|
||||
public IUpdate<T1> UpdateColumns(Expression<Func<T1, object>> columns) => UpdateColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null));
|
||||
public IUpdate<T1> IgnoreColumns(Expression<Func<T1, object>> columns) => IgnoreColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null));
|
||||
public IUpdate<T1> UpdateColumns(Expression<Func<T1, object>> columns) => UpdateColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null));
|
||||
|
||||
public IUpdate<T1> IgnoreColumns(string[] columns)
|
||||
{
|
||||
@ -493,7 +493,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
if (tempPrimarys != null)
|
||||
{
|
||||
var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, tempPrimarys?.Body, false, null).Distinct().ToDictionary(a => a);
|
||||
var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, tempPrimarys?.Body, false, null).Distinct().ToDictionary(a => a);
|
||||
_tempPrimarys = cols.Keys.Select(a => _table.ColumnsByCs.TryGetValue(a, out var col) ? col : null).ToArray().Where(a => a != null).ToArray();
|
||||
}
|
||||
return this;
|
||||
@ -525,7 +525,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
public IUpdate<T1> Set<TMember>(Expression<Func<T1, TMember>> column, TMember value)
|
||||
{
|
||||
var cols = new List<SelectColumnInfo>();
|
||||
_commonExpression.ExpressionSelectColumn_MemberAccess(null, cols, SelectTableInfoType.From, column?.Body, true, null);
|
||||
_commonExpression.ExpressionSelectColumn_MemberAccess(null, null, cols, SelectTableInfoType.From, column?.Body, true, null);
|
||||
if (cols.Count != 1) return this;
|
||||
SetPriv(cols.First().Column, value);
|
||||
return this;
|
||||
@ -544,7 +544,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
case ExpressionType.Equal:
|
||||
var equalBinaryExp = body as BinaryExpression;
|
||||
var eqval = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, body, null, null);
|
||||
var eqval = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, null, _table, null, body, null, null);
|
||||
if (eqval.EndsWith(" IS NULL")) eqval = $"{eqval.Remove(eqval.Length - 10)} = NULL"; //#311
|
||||
_set.Append(", ").Append(eqval);
|
||||
return this;
|
||||
@ -590,7 +590,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (body is BinaryExpression == false &&
|
||||
nodeType != ExpressionType.Call) return this;
|
||||
var cols = new List<SelectColumnInfo>();
|
||||
var expt = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, cols, body, null, null);
|
||||
var expt = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, null, _table, cols, body, null, null);
|
||||
if (cols.Any() == false) return this;
|
||||
foreach (var col in cols)
|
||||
{
|
||||
@ -642,7 +642,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
public IUpdate<T1> WhereIf(bool condition, Expression<Func<T1, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
return this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null, _params));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, null, _table, null, exp?.Body, null, _params));
|
||||
}
|
||||
public IUpdate<T1> Where(string sql, object parms = null)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace FreeSql.KingbaseES
|
||||
if (columns != null)
|
||||
{
|
||||
var colsList = new List<ColumnInfo>();
|
||||
var cols = _insert.InternalCommonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).ToDictionary(a => a, a => true);
|
||||
var cols = _insert.InternalCommonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null).ToDictionary(a => a, a => true);
|
||||
foreach (var col in _insert.InternalTable.Columns.Values)
|
||||
if (cols.ContainsKey(col.Attribute.Name))
|
||||
colsList.Add(col);
|
||||
|
@ -258,7 +258,6 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
|
||||
if (ds == null) return loc1;
|
||||
|
||||
var position = 0;
|
||||
foreach (object[] row in ds)
|
||||
{
|
||||
var object_id = string.Concat(row[0]);
|
||||
@ -308,7 +307,7 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
Table = loc2[object_id],
|
||||
Comment = comment,
|
||||
DefaultValue = defaultValue,
|
||||
Position = ++position
|
||||
Position = attnum
|
||||
});
|
||||
loc3[object_id][column].DbType = this.GetDbType(loc3[object_id][column]);
|
||||
loc3[object_id][column].CsType = this.GetCsTypeInfo(loc3[object_id][column]);
|
||||
|
@ -30,7 +30,7 @@ namespace FreeSql.Odbc.KingbaseES
|
||||
if (columns != null)
|
||||
{
|
||||
var colsList = new List<ColumnInfo>();
|
||||
var cols = _pgsqlInsert.InternalCommonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).ToDictionary(a => a, a => true);
|
||||
var cols = _pgsqlInsert.InternalCommonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null).ToDictionary(a => a, a => true);
|
||||
foreach (var col in _pgsqlInsert.InternalTable.Columns.Values)
|
||||
if (cols.ContainsKey(col.Attribute.Name))
|
||||
colsList.Add(col);
|
||||
|
@ -259,7 +259,6 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
|
||||
if (ds == null) return loc1;
|
||||
|
||||
var position = 0;
|
||||
foreach (object[] row in ds)
|
||||
{
|
||||
var object_id = string.Concat(row[0]);
|
||||
@ -309,7 +308,7 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
Table = loc2[object_id],
|
||||
Comment = comment,
|
||||
DefaultValue = defaultValue,
|
||||
Position = ++position
|
||||
Position = attnum
|
||||
});
|
||||
loc3[object_id][column].DbType = this.GetDbType(loc3[object_id][column]);
|
||||
loc3[object_id][column].CsType = this.GetCsTypeInfo(loc3[object_id][column]);
|
||||
|
@ -30,7 +30,7 @@ namespace FreeSql.Odbc.PostgreSQL
|
||||
if (columns != null)
|
||||
{
|
||||
var colsList = new List<ColumnInfo>();
|
||||
var cols = _pgsqlInsert.InternalCommonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).ToDictionary(a => a, a => true);
|
||||
var cols = _pgsqlInsert.InternalCommonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null).ToDictionary(a => a, a => true);
|
||||
foreach (var col in _pgsqlInsert.InternalTable.Columns.Values)
|
||||
if (cols.ContainsKey(col.Attribute.Name))
|
||||
colsList.Add(col);
|
||||
|
@ -273,7 +273,6 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
|
||||
if (ds == null) return loc1;
|
||||
|
||||
var position = 0;
|
||||
foreach (object[] row in ds)
|
||||
{
|
||||
var object_id = string.Concat(row[0]);
|
||||
@ -324,7 +323,7 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
Table = loc2[object_id],
|
||||
Comment = comment,
|
||||
DefaultValue = defaultValue,
|
||||
Position = ++position
|
||||
Position = attnum
|
||||
});
|
||||
loc3[object_id][column].DbType = this.GetDbType(loc3[object_id][column]);
|
||||
loc3[object_id][column].CsType = this.GetCsTypeInfo(loc3[object_id][column]);
|
||||
|
@ -30,7 +30,7 @@ namespace FreeSql.PostgreSQL.Curd
|
||||
if (columns != null)
|
||||
{
|
||||
var colsList = new List<ColumnInfo>();
|
||||
var cols = _pgsqlInsert.InternalCommonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).ToDictionary(a => a, a => true);
|
||||
var cols = _pgsqlInsert.InternalCommonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null).ToDictionary(a => a, a => true);
|
||||
foreach (var col in _pgsqlInsert.InternalTable.Columns.Values)
|
||||
if (cols.ContainsKey(col.Attribute.Name))
|
||||
colsList.Add(col);
|
||||
|
@ -381,7 +381,6 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
|
||||
if (ds == null) return loc1;
|
||||
|
||||
var position = 0;
|
||||
foreach (object[] row in ds)
|
||||
{
|
||||
var object_id = string.Concat(row[0]);
|
||||
@ -432,7 +431,7 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
Table = loc2[object_id],
|
||||
Comment = comment,
|
||||
DefaultValue = defaultValue,
|
||||
Position = ++position
|
||||
Position = attnum
|
||||
});
|
||||
loc3[object_id][column].DbType = this.GetDbType(loc3[object_id][column]);
|
||||
loc3[object_id][column].CsType = this.GetCsTypeInfo(loc3[object_id][column]);
|
||||
|
@ -277,7 +277,6 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
|
||||
if (ds == null) return loc1;
|
||||
|
||||
var position = 0;
|
||||
foreach (object[] row in ds)
|
||||
{
|
||||
var object_id = string.Concat(row[0]);
|
||||
@ -327,7 +326,7 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
Table = loc2[object_id],
|
||||
Comment = comment,
|
||||
DefaultValue = defaultValue,
|
||||
Position = ++position
|
||||
Position = attnum
|
||||
});
|
||||
loc3[object_id][column].DbType = this.GetDbType(loc3[object_id][column]);
|
||||
loc3[object_id][column].CsType = this.GetCsTypeInfo(loc3[object_id][column]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user