mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-17 19:43:21 +08:00
- 优化 ISelect<object> AsType 的父子类转换时的情况;#1427
This commit is contained in:
parent
f295f2cd1a
commit
3d205041b0
@ -465,6 +465,16 @@ namespace base_entity
|
||||
public string Name { get; set; }
|
||||
public Point Center { get; set; }
|
||||
}
|
||||
public abstract class BaseEntity2
|
||||
{
|
||||
[Column(IsPrimary = true, IsIdentity = true)]
|
||||
public long Id { get; set; }
|
||||
}
|
||||
|
||||
public class Student : BaseEntity2
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
@ -526,7 +536,7 @@ namespace base_entity
|
||||
|
||||
.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")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower)
|
||||
|
||||
@ -560,6 +570,26 @@ namespace base_entity
|
||||
#endregion
|
||||
fsql.UseJsonMap();
|
||||
|
||||
var type = typeof(Student);
|
||||
|
||||
var sw111 = fsql.Queryable<object>()
|
||||
.AsType(type)
|
||||
.Where(s => (s as BaseEntity2).Id == 1)
|
||||
.ToSql();
|
||||
|
||||
Console.WriteLine(sw111);
|
||||
|
||||
var testsql01 = fsql.Select<User1>()
|
||||
//.GroupBy(a => new { a.Avatar, a.GroupId })
|
||||
//.Having(g => g.Sum(g.Value.Sort) > 0)
|
||||
.WithTempQuery(a => new
|
||||
{
|
||||
a.Avatar, a.GroupId, sum1 = SqlExt.Sum(a.Sort).ToValue()
|
||||
})
|
||||
.Where(a => a.sum1 > 0)
|
||||
.ToSql();
|
||||
|
||||
|
||||
fsql.Aop.ParseExpression += (_, e) =>
|
||||
{
|
||||
if (fsql.Ado.DataType == DataType.PostgreSQL)
|
||||
|
@ -800,14 +800,5 @@
|
||||
<param name="that"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
||||
<summary>
|
||||
批量注入 Repository,可以参考代码自行调整
|
||||
</summary>
|
||||
<param name="services"></param>
|
||||
<param name="globalDataFilter"></param>
|
||||
<param name="assemblies"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
@ -1723,6 +1723,8 @@ namespace FreeSql.Internal
|
||||
expStack.Push(oper2Parm);
|
||||
else if (oper2Parm.Type != typeof(object) && oper2Parm.Type.IsAssignableFrom(exp2.Type))
|
||||
expStack.Push(oper2Parm);
|
||||
else if (oper2Parm.Type == typeof(object) && tsc._tables[0].Table != null && exp2.Type.IsAssignableFrom(tsc._tables[0].Table.Type) == true)
|
||||
expStack.Push(oper2Parm);
|
||||
else
|
||||
expStack.Push(Expression.Parameter(exp2.Type, oper2Parm.Name));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user