mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 修复 BaseEntity 子查询 .Where 问题;#1586
This commit is contained in:
parent
d2f4bfb6f5
commit
7e9fc55bc0
@ -559,16 +559,16 @@ namespace base_entity
|
|||||||
//.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5")
|
//.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5")
|
||||||
//.UseQuoteSqlName(false)
|
//.UseQuoteSqlName(false)
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")
|
||||||
|
|
||||||
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
|
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
|
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
|
||||||
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
|
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
|
||||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower)
|
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower)
|
||||||
|
|
||||||
.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=2")
|
//.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=2")
|
||||||
.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.Dameng, "server=127.0.0.1;port=5236;user=2user;password=123456789;database=2user;poolsize=5;")
|
//.UseConnectionString(FreeSql.DataType.Dameng, "server=127.0.0.1;port=5236;user=2user;password=123456789;database=2user;poolsize=5;")
|
||||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||||
@ -600,6 +600,15 @@ namespace base_entity
|
|||||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
var xxxc1 = User1.Select.ToSql(a => new
|
||||||
|
{
|
||||||
|
count = User1.Where(b => b.Id == a.Id).Count()
|
||||||
|
});
|
||||||
|
|
||||||
|
var tididentity = fsql.CodeFirst.GetTableByEntity(typeof(TestIdAndIdentity));
|
||||||
|
|
||||||
|
var tididDDL = fsql.CodeFirst.GetComparisonDDLStatements(typeof(TestIdAndIdentity));
|
||||||
|
|
||||||
var lstKafka = fsql.Ado.Query<ProducerModel_Kafka>("SELECT 123 AS ID,'10.0.0.0' AS IP FROM dual ");
|
var lstKafka = fsql.Ado.Query<ProducerModel_Kafka>("SELECT 123 AS ID,'10.0.0.0' AS IP FROM dual ");
|
||||||
|
|
||||||
|
|
||||||
@ -2558,4 +2567,12 @@ var sql11111 = fsql.Select<Class1111>()
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ProducerConfig PConfig { get; set; }
|
public ProducerConfig PConfig { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TestIdAndIdentity
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public int IdentityId { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1255,31 +1255,34 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (new[] { "Where", "WhereIf" }.Contains(exp3tmpCall.Method.Name) && exp3tmpCall.Object != null)
|
if (new[] { "Where", "WhereIf" }.Contains(exp3tmpCall.Method.Name))
|
||||||
{
|
{
|
||||||
//这段特别兼容 DbSet.Where 表达式解析 #216
|
//if (exp3tmpCall.Object != null) //BaseEntity.Where 也需要兼容
|
||||||
var exp3tmpTestCall = Expression.Call(exp3tmpCall.Object, exp3tmpCall.Method, exp3tmpCall.Arguments.Select(a =>
|
|
||||||
{
|
{
|
||||||
var a2 = a;
|
//这段特别兼容 DbSet.Where 表达式解析 #216
|
||||||
if (a2.NodeType == ExpressionType.Quote) a2 = (a as UnaryExpression)?.Operand;
|
var exp3tmpTestCall = Expression.Call(exp3tmpCall.Object, exp3tmpCall.Method, exp3tmpCall.Arguments.Select(a =>
|
||||||
if (a2?.NodeType == ExpressionType.Lambda)
|
|
||||||
{
|
{
|
||||||
var alambda = a2 as LambdaExpression;
|
var a2 = a;
|
||||||
if (alambda.ReturnType == typeof(bool))
|
if (a2.NodeType == ExpressionType.Quote) a2 = (a as UnaryExpression)?.Operand;
|
||||||
return Expression.Constant(null, a.Type);// Expression.Lambda(Expression.Constant(true), alambda.Parameters);
|
if (a2?.NodeType == ExpressionType.Lambda)
|
||||||
}
|
{
|
||||||
return a;
|
var alambda = a2 as LambdaExpression;
|
||||||
//if (a.Type == typeof(Expression<>).MakeGenericType(typeof(Func<,>).MakeGenericType(exp3tmp.Type.GetGenericArguments()[0], typeof(bool))))
|
if (alambda.ReturnType == typeof(bool))
|
||||||
// return Expression.Lambda(Expression.Constant(true),
|
return Expression.Constant(null, a.Type);// Expression.Lambda(Expression.Constant(true), alambda.Parameters);
|
||||||
}).ToArray());
|
}
|
||||||
fsql = Expression.Lambda(exp3tmpTestCall).Compile().DynamicInvoke();
|
return a;
|
||||||
var fsqlFindMethod = fsql.GetType().GetMethod(exp3tmpCall.Method.Name, exp3tmpCall.Arguments.Select(a => a.Type).ToArray());
|
//if (a.Type == typeof(Expression<>).MakeGenericType(typeof(Func<,>).MakeGenericType(exp3tmp.Type.GetGenericArguments()[0], typeof(bool))))
|
||||||
if (fsqlFindMethod == null)
|
// return Expression.Lambda(Expression.Constant(true),
|
||||||
throw new Exception(CoreStrings.Unable_Parse_ExpressionMethod(exp3tmpCall.Method.Name));
|
}).ToArray());
|
||||||
var exp3StackOld = exp3Stack;
|
fsql = Expression.Lambda(exp3tmpTestCall).Compile().DynamicInvoke();
|
||||||
exp3Stack = new Stack<Expression>();
|
var fsqlFindMethod = fsql.GetType().GetMethod(exp3tmpCall.Method.Name, exp3tmpCall.Arguments.Select(a => a.Type).ToArray());
|
||||||
exp3Stack.Push(Expression.Call(Expression.Constant(fsql), fsqlFindMethod, exp3tmpCall.Arguments));
|
if (fsqlFindMethod == null)
|
||||||
while (exp3StackOld.Any()) exp3Stack.Push(exp3StackOld.Pop());
|
throw new Exception(CoreStrings.Unable_Parse_ExpressionMethod(exp3tmpCall.Method.Name));
|
||||||
|
var exp3StackOld = exp3Stack;
|
||||||
|
exp3Stack = new Stack<Expression>();
|
||||||
|
exp3Stack.Push(Expression.Call(Expression.Constant(fsql), fsqlFindMethod, exp3tmpCall.Arguments));
|
||||||
|
while (exp3StackOld.Any()) exp3Stack.Push(exp3StackOld.Pop());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fsql == null)
|
if (fsql == null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user