- 优化 WithTempQuery 多对象选择同别名问题;#1192

This commit is contained in:
2881099 2022-09-25 00:16:15 +08:00
parent 93ea581281
commit e91f1157d8
11 changed files with 210 additions and 79 deletions

View File

@ -733,6 +733,15 @@
<param name="modelBuilder"></param> <param name="modelBuilder"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:FreeSqlDbContextExtensions.ApplyConfigurationsFromAssembly(FreeSql.ICodeFirst,System.Reflection.Assembly,System.Func{System.Type,System.Boolean})">
<summary>
根据Assembly扫描所有继承IEntityTypeConfiguration&lt;T&gt;的配置类
</summary>
<param name="codeFirst"></param>
<param name="assembly"></param>
<param name="predicate"></param>
<returns></returns>
</member>
<member name="M:FreeSqlDbContextExtensions.CreateDbContext(IFreeSql)"> <member name="M:FreeSqlDbContextExtensions.CreateDbContext(IFreeSql)">
<summary> <summary>
创建普通数据上下文档对象 创建普通数据上下文档对象

View File

@ -36,7 +36,7 @@ ORDER BY b.""Name"", b.""ID""", people1);
.ToSql(); .ToSql();
Assert.Equal(@"SELECT * Assert.Equal(@"SELECT *
FROM ( FROM (
SELECT replace(replace(a.""Name"", ' ', ''), ' ', ''), a.""CSNY"" SELECT replace(replace(a.""Name"", ' ', ''), ' ', '') ""xm_new"", a.""CSNY"" ""csny""
FROM ""people_issues_1237"" a FROM ""people_issues_1237"" a
GROUP BY replace(replace(a.""Name"", ' ', ''), ' ', ''), a.""CSNY"" GROUP BY replace(replace(a.""Name"", ' ', ''), ' ', ''), a.""CSNY""
HAVING (count(1) > 1) ) a HAVING (count(1) > 1) ) a

View File

@ -17,7 +17,7 @@ namespace FreeSql.Tests.KingbaseES
[Column(IsIdentity = true, IsPrimary = true)] [Column(IsIdentity = true, IsPrimary = true)]
public int Id { get; set; } public int Id { get; set; }
public int Clicks { get; set; } public int Clicks { get; set; }
public int TypeGuid { get; set; } public int TypeGuid223 { get; set; }
public TestTypeInfo Type { get; set; } public TestTypeInfo Type { get; set; }
public string Title { get; set; } public string Title { get; set; }
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
@ -168,10 +168,10 @@ namespace FreeSql.Tests.KingbaseES
var testDto3 = select.Limit(10).ToList(a => new TestDto { }); var testDto3 = select.Limit(10).ToList(a => new TestDto { });
var testDto4 = select.Limit(10).ToList(a => new TestDto() { }); var testDto4 = select.Limit(10).ToList(a => new TestDto() { });
var testDto11 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto { id = a.Id, name = a.Title }); var testDto11 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList(a => new TestDto { id = a.Id, name = a.Title });
var testDto22 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto()); var testDto22 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList(a => new TestDto());
var testDto33 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto { }); var testDto33 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList(a => new TestDto { });
var testDto44 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto() { }); var testDto44 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList(a => new TestDto() { });
var testDto211 = select.Limit(10).ToList(a => new TestDto2(a.Id, a.Title)); var testDto211 = select.Limit(10).ToList(a => new TestDto2(a.Id, a.Title));
var testDto212 = select.Limit(10).ToList(a => new TestDto2()); var testDto212 = select.Limit(10).ToList(a => new TestDto2());
@ -179,11 +179,11 @@ namespace FreeSql.Tests.KingbaseES
var testDto214 = select.Limit(10).ToList(a => new TestDto2() { }); var testDto214 = select.Limit(10).ToList(a => new TestDto2() { });
var testDto215 = select.Limit(10).ToList<TestDto2>(); var testDto215 = select.Limit(10).ToList<TestDto2>();
var testDto2211 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2(a.Id, a.Title)); var testDto2211 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList(a => new TestDto2(a.Id, a.Title));
var testDto2222 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2()); var testDto2222 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList(a => new TestDto2());
var testDto2233 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2 { }); var testDto2233 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList(a => new TestDto2 { });
var testDto2244 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2() { }); var testDto2244 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList(a => new TestDto2() { });
var testDto2255 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList<TestDto2>(); var testDto2255 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).Limit(10).ToList<TestDto2>();
g.kingbaseES.Insert<TestGuidIdToList>().AppendData(new TestGuidIdToList()).ExecuteAffrows(); g.kingbaseES.Insert<TestGuidIdToList>().AppendData(new TestGuidIdToList()).ExecuteAffrows();
var testGuidId5 = g.kingbaseES.Select<TestGuidIdToList>().ToList(); var testGuidId5 = g.kingbaseES.Select<TestGuidIdToList>().ToList();
@ -276,7 +276,7 @@ namespace FreeSql.Tests.KingbaseES
var sql2222Tolist = sql2222.ToList(); var sql2222Tolist = sql2222.ToList();
var collectionSelect = select.Where(a => var collectionSelect = select.Where(a =>
a.Type.Guid == a.TypeGuid && a.Type.Guid == a.TypeGuid223 &&
a.Type.Parent.Id == a.Type.ParentId && a.Type.Parent.Id == a.Type.ParentId &&
a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any(b => b.ParentId == a.Type.Parent.Id) a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any(b => b.ParentId == a.Type.Parent.Id)
); );
@ -310,14 +310,14 @@ namespace FreeSql.Tests.KingbaseES
public void From() public void From()
{ {
var query2 = select.From<TestTypeInfo>((s, b) => s var query2 = select.From<TestTypeInfo>((s, b) => s
.LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => a.TypeGuid223 == b.Guid)
); );
var sql2 = query2.ToSql().Replace("\r\n", ""); var sql2 = query2.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON a.\"TYPEGUID\" = b.\"GUID\"", sql2); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON a.\"TYPEGUID\" = b.\"GUID\"", sql2);
query2.ToList(); query2.ToList();
var query3 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s var query3 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
.LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => a.TypeGuid223 == b.Guid)
.LeftJoin(a => b.ParentId == c.Id) .LeftJoin(a => b.ParentId == c.Id)
); );
var sql3 = query3.ToSql().Replace("\r\n", ""); var sql3 = query3.ToSql().Replace("\r\n", "");
@ -328,47 +328,47 @@ namespace FreeSql.Tests.KingbaseES
public void LeftJoin() public void LeftJoin()
{ {
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid); var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223);
var sql = query.ToSql().Replace("\r\n", ""); var sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\"", sql);
query.ToList(); query.ToList();
query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223 && a.Type.Name == "xxx");
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx'", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx'", sql);
query.ToList(); query.ToList();
query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223 && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql);
query.ToList(); query.ToList();
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid); query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\"", sql);
query.ToList(); query.ToList();
query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223 && b.Name == "xxx");
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'xxx'", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'xxx'", sql);
query.ToList(); query.ToList();
query = select.LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid && a__Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); query = select.LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid223 && a__Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql);
query.ToList(); query.ToList();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select query = select
.LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Guid == a.TypeGuid223)
.LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId); .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql);
query.ToList(); query.ToList();
query = select query = select
.LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid) .LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid223)
.LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId); .LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = a__Type.\"PARENTID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = a__Type.\"PARENTID\"", sql);
@ -376,7 +376,7 @@ namespace FreeSql.Tests.KingbaseES
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
.LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => a.TypeGuid223 == b.Guid)
.LeftJoin(a => b.ParentId == c.Id)); .LeftJoin(a => b.ParentId == c.Id));
sql = query2.ToSql().Replace("\r\n", ""); sql = query2.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON a.\"TYPEGUID\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" b ON a.\"TYPEGUID\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql);
@ -392,47 +392,49 @@ namespace FreeSql.Tests.KingbaseES
public void InnerJoin() public void InnerJoin()
{ {
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid); var tb = g.kingbaseES.CodeFirst.GetTableByEntity(typeof(Topic));
var query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid223);
var sql = query.ToSql().Replace("\r\n", ""); var sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\"", sql);
query.ToList(); query.ToList();
query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid223 && a.Type.Name == "xxx");
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx'", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx'", sql);
query.ToList(); query.ToList();
query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); query = select.InnerJoin(a => a.Type.Guid == a.TypeGuid223 && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql);
query.ToList(); query.ToList();
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid); query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\"", sql);
query.ToList(); query.ToList();
query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223 && b.Name == "xxx");
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'xxx'", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'xxx'", sql);
query.ToList(); query.ToList();
query = select.InnerJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid && a__Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); query = select.InnerJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid223 && a__Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql);
query.ToList(); query.ToList();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select query = select
.InnerJoin(a => a.Type.Guid == a.TypeGuid) .InnerJoin(a => a.Type.Guid == a.TypeGuid223)
.InnerJoin(a => a.Type.Parent.Id == a.Type.ParentId); .InnerJoin(a => a.Type.Parent.Id == a.Type.ParentId);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" INNER JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" INNER JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql);
query.ToList(); query.ToList();
query = select query = select
.InnerJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid) .InnerJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid223)
.InnerJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId); .InnerJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" INNER JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = a__Type.\"PARENTID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" INNER JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = a__Type.\"PARENTID\"", sql);
@ -440,7 +442,7 @@ namespace FreeSql.Tests.KingbaseES
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
.InnerJoin(a => a.TypeGuid == b.Guid) .InnerJoin(a => a.TypeGuid223 == b.Guid)
.InnerJoin(a => b.ParentId == c.Id)); .InnerJoin(a => b.ParentId == c.Id));
sql = query2.ToSql().Replace("\r\n", ""); sql = query2.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON a.\"TYPEGUID\" = b.\"GUID\" INNER JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a INNER JOIN \"TESTTYPEINFO\" b ON a.\"TYPEGUID\" = b.\"GUID\" INNER JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql);
@ -456,47 +458,47 @@ namespace FreeSql.Tests.KingbaseES
public void RightJoin() public void RightJoin()
{ {
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var query = select.RightJoin(a => a.Type.Guid == a.TypeGuid); var query = select.RightJoin(a => a.Type.Guid == a.TypeGuid223);
var sql = query.ToSql().Replace("\r\n", ""); var sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\"", sql);
query.ToList(); query.ToList();
query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx"); query = select.RightJoin(a => a.Type.Guid == a.TypeGuid223 && a.Type.Name == "xxx");
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx'", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx'", sql);
query.ToList(); query.ToList();
query = select.RightJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); query = select.RightJoin(a => a.Type.Guid == a.TypeGuid223 && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql);
query.ToList(); query.ToList();
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid); query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\"", sql);
query.ToList(); query.ToList();
query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx"); query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223 && b.Name == "xxx");
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'xxx'", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'xxx'", sql);
query.ToList(); query.ToList();
query = select.RightJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid && a__Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10); query = select.RightJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid223 && a__Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql);
query.ToList(); query.ToList();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select query = select
.RightJoin(a => a.Type.Guid == a.TypeGuid) .RightJoin(a => a.Type.Guid == a.TypeGuid223)
.RightJoin(a => a.Type.Parent.Id == a.Type.ParentId); .RightJoin(a => a.Type.Parent.Id == a.Type.ParentId);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql);
query.ToList(); query.ToList();
query = select query = select
.RightJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid) .RightJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid223)
.RightJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId); .RightJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = a__Type.\"PARENTID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" c ON c.\"ID\" = a__Type.\"PARENTID\"", sql);
@ -504,7 +506,7 @@ namespace FreeSql.Tests.KingbaseES
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
.RightJoin(a => a.TypeGuid == b.Guid) .RightJoin(a => a.TypeGuid223 == b.Guid)
.RightJoin(a => b.ParentId == c.Id)); .RightJoin(a => b.ParentId == c.Id));
sql = query2.ToSql().Replace("\r\n", ""); sql = query2.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON a.\"TYPEGUID\" = b.\"GUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a RIGHT JOIN \"TESTTYPEINFO\" b ON a.\"TYPEGUID\" = b.\"GUID\" RIGHT JOIN \"TESTTYPEPARENTINFO\" c ON b.\"PARENTID\" = c.\"ID\"", sql);
@ -546,7 +548,7 @@ namespace FreeSql.Tests.KingbaseES
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" WHERE (a__Type.\"NAME\" = 'typeTitle')", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" WHERE (a__Type.\"NAME\" = 'typeTitle')", sql);
query.ToList(); query.ToList();
query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid223);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" WHERE (a__Type.\"NAME\" = 'typeTitle' AND a__Type.\"GUID\" = a.\"TYPEGUID\")", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" WHERE (a__Type.\"NAME\" = 'typeTitle' AND a__Type.\"GUID\" = a.\"TYPEGUID\")", sql);
query.ToList(); query.ToList();
@ -557,12 +559,12 @@ namespace FreeSql.Tests.KingbaseES
query.ToList(); query.ToList();
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3>򵥶<EFBFBD><F2B5A5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3>򵥶<EFBFBD><F2B5A5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select.Where<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "typeTitle"); query = select.Where<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223 && b.Name == "typeTitle");
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" b WHERE (b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'typeTitle')", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" b WHERE (b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'typeTitle')", sql);
query.ToList(); query.ToList();
query = select.Where<TestTypeInfo>((a, b) => b.Name == "typeTitle" && b.Guid == a.TypeGuid); query = select.Where<TestTypeInfo>((a, b) => b.Name == "typeTitle" && b.Guid == a.TypeGuid223);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" b WHERE (b.\"NAME\" = 'typeTitle' AND b.\"GUID\" = a.\"TYPEGUID\")", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a, \"TESTTYPEINFO\" b WHERE (b.\"NAME\" = 'typeTitle' AND b.\"GUID\" = a.\"TYPEGUID\")", sql);
query.ToList(); query.ToList();
@ -604,7 +606,7 @@ namespace FreeSql.Tests.KingbaseES
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" WHERE (a__Type.\"NAME\" = 'typeTitle')", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" WHERE (a__Type.\"NAME\" = 'typeTitle')", sql);
query.ToList(); query.ToList();
query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid223);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" WHERE (a__Type.\"NAME\" = 'typeTitle' AND a__Type.\"GUID\" = a.\"TYPEGUID\")", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a LEFT JOIN \"TESTTYPEINFO\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" WHERE (a__Type.\"NAME\" = 'typeTitle' AND a__Type.\"GUID\" = a.\"TYPEGUID\")", sql);
query.ToList(); query.ToList();
@ -645,7 +647,7 @@ namespace FreeSql.Tests.KingbaseES
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql);
query.ToList(); query.ToList();
query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid); query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TypeGuid223);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a", sql);
query.ToList(); query.ToList();
@ -706,7 +708,7 @@ namespace FreeSql.Tests.KingbaseES
g.kingbaseES.Insert<TestInfo>().AppendData(new TestInfo { Title = "Title" + DateTime.Now.ToString("yyyyMMddHHmmss"), CreateTime = DateTime.Now, TypeGuid = (int)testpid1 }).ExecuteAffrows(); g.kingbaseES.Insert<TestInfo>().AppendData(new TestInfo { Title = "Title" + DateTime.Now.ToString("yyyyMMddHHmmss"), CreateTime = DateTime.Now, TypeGuid = (int)testpid1 }).ExecuteAffrows();
var fkfjfj = select.GroupBy(a => a.Title) var fkfjfj = select.GroupBy(a => a.Title)
.ToList(a => a.Sum(a.Value.TypeGuid)); .ToList(a => a.Sum(a.Value.TypeGuid223));
var aggsql1 = select var aggsql1 = select
.GroupBy(a => a.Title) .GroupBy(a => a.Title)
@ -714,7 +716,7 @@ namespace FreeSql.Tests.KingbaseES
{ {
b.Key, b.Key,
cou = b.Count(), cou = b.Count(),
sum2 = b.Sum(b.Value.TypeGuid) sum2 = b.Sum(b.Value.TypeGuid223)
}); });
var aggtolist1 = select var aggtolist1 = select
.GroupBy(a => a.Title) .GroupBy(a => a.Title)
@ -722,7 +724,7 @@ namespace FreeSql.Tests.KingbaseES
{ {
b.Key, b.Key,
cou = b.Count(), cou = b.Count(),
sum2 = b.Sum(b.Value.TypeGuid) sum2 = b.Sum(b.Value.TypeGuid223)
}); });
var aggtolist11 = select var aggtolist11 = select
.GroupBy(a => a.Title) .GroupBy(a => a.Title)
@ -730,7 +732,7 @@ namespace FreeSql.Tests.KingbaseES
{ {
b.Key, b.Key,
cou = b.Count(), cou = b.Count(),
sum2 = b.Sum(b.Value.TypeGuid) sum2 = b.Sum(b.Value.TypeGuid223)
}); });
var aggsql2 = select var aggsql2 = select
@ -741,7 +743,7 @@ namespace FreeSql.Tests.KingbaseES
b.Key.yyyy, b.Key.yyyy,
cou = b.Count(), cou = b.Count(),
sum2 = b.Sum(b.Value.TypeGuid) sum2 = b.Sum(b.Value.TypeGuid223)
}); });
var aggtolist2 = select var aggtolist2 = select
.GroupBy(a => new { a.Title, yyyy = string.Concat(a.CreateTime.Year, '-', a.CreateTime.Month) }) .GroupBy(a => new { a.Title, yyyy = string.Concat(a.CreateTime.Year, '-', a.CreateTime.Month) })
@ -750,7 +752,7 @@ namespace FreeSql.Tests.KingbaseES
b.Key.Title, b.Key.Title,
b.Key.yyyy, b.Key.yyyy,
cou = b.Count(), cou = b.Count(),
sum2 = b.Sum(b.Value.TypeGuid) sum2 = b.Sum(b.Value.TypeGuid223)
}); });
var aggtolist22 = select var aggtolist22 = select
.GroupBy(a => new { a.Title, yyyy = string.Concat(a.CreateTime.Year, '-', a.CreateTime.Month) }) .GroupBy(a => new { a.Title, yyyy = string.Concat(a.CreateTime.Year, '-', a.CreateTime.Month) })
@ -760,7 +762,7 @@ namespace FreeSql.Tests.KingbaseES
b.Key.yyyy, b.Key.yyyy,
b.Key, b.Key,
cou = b.Count(), cou = b.Count(),
sum2 = b.Sum(b.Value.TypeGuid) sum2 = b.Sum(b.Value.TypeGuid223)
}); });
var aggsql3 = select var aggsql3 = select
@ -769,7 +771,7 @@ namespace FreeSql.Tests.KingbaseES
{ {
b.Key, b.Key,
cou = b.Count(), cou = b.Count(),
sum2 = b.Sum(b.Value.TypeGuid), sum2 = b.Sum(b.Value.TypeGuid223),
sum3 = b.Sum(b.Value.Type.Parent.Id) sum3 = b.Sum(b.Value.Type.Parent.Id)
}); });
} }
@ -927,47 +929,47 @@ WHERE ((((a.""ID"")::text) in (SELECT b.""TITLE""
}; };
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).AsTable(tableRule); var query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223).AsTable(tableRule);
var sql = query.ToSql().Replace("\r\n", ""); var sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\"", sql);
query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").AsTable(tableRule); query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223 && a.Type.Name == "xxx").AsTable(tableRule);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx'", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx'", sql);
query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); query = select.LeftJoin(a => a.Type.Guid == a.TypeGuid223 && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTIN_AT\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTIN_AT\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql);
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid).AsTable(tableRule); query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223).AsTable(tableRule);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" b ON b.\"GUID\" = a.\"TYPEGUID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" b ON b.\"GUID\" = a.\"TYPEGUID\"", sql);
query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid && b.Name == "xxx").AsTable(tableRule); query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TypeGuid223 && b.Name == "xxx").AsTable(tableRule);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" b ON b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'xxx'", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" b ON b.\"GUID\" = a.\"TYPEGUID\" AND b.\"NAME\" = 'xxx'", sql);
query = select.LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid && a__Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule); query = select.LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid223 && a__Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10).AsTable(tableRule);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTIN_AT\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" AND a__Type.\"NAME\" = 'xxx' LEFT JOIN \"TESTTYPEPARENTIN_AT\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\" WHERE (a__Type__Parent.\"ID\" = 10)", sql);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
query = select query = select
.LeftJoin(a => a.Type.Guid == a.TypeGuid) .LeftJoin(a => a.Type.Guid == a.TypeGuid223)
.LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).AsTable(tableRule); .LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId).AsTable(tableRule);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" LEFT JOIN \"TESTTYPEPARENTIN_AT\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" LEFT JOIN \"TESTTYPEPARENTIN_AT\" a__Type__Parent ON a__Type__Parent.\"ID\" = a__Type.\"PARENTID\"", sql);
query = select query = select
.LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid) .LeftJoin<TestTypeInfo>((a, a__Type) => a__Type.Guid == a.TypeGuid223)
.LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule); .LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId).AsTable(tableRule);
sql = query.ToSql().Replace("\r\n", ""); sql = query.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" LEFT JOIN \"TESTTYPEPARENTIN_AT\" c ON c.\"ID\" = a__Type.\"PARENTID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a__Type.\"GUID\", a__Type.\"PARENTID\", a__Type.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" a__Type ON a__Type.\"GUID\" = a.\"TYPEGUID\" LEFT JOIN \"TESTTYPEPARENTIN_AT\" c ON c.\"ID\" = a__Type.\"PARENTID\"", sql);
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ //<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
.LeftJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => a.TypeGuid223 == b.Guid)
.LeftJoin(a => b.ParentId == c.Id)).AsTable(tableRule); .LeftJoin(a => b.ParentId == c.Id)).AsTable(tableRule);
sql = query2.ToSql().Replace("\r\n", ""); sql = query2.ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" b ON a.\"TYPEGUID\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTIN_AT\" c ON b.\"PARENTID\" = c.\"ID\"", sql); Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", b.\"GUID\", b.\"PARENTID\", b.\"NAME\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22_T1\" a LEFT JOIN \"TESTTYPEINFO_T2\" b ON a.\"TYPEGUID\" = b.\"GUID\" LEFT JOIN \"TESTTYPEPARENTIN_AT\" c ON b.\"PARENTID\" = c.\"ID\"", sql);

View File

@ -1711,6 +1711,97 @@ WHERE (a.[rownum] = 1) AND ((a.[Nickname] = N'name02' OR a.[Nickname] = N'name03
Assert.Equal("name03", list16[1].user.Nickname); Assert.Equal("name03", list16[1].user.Nickname);
Assert.Equal(0, list16[1].subquery1); Assert.Equal(0, list16[1].subquery1);
Assert.Equal(0, list16[1].subquery2); Assert.Equal(0, list16[1].subquery2);
var sql17 = fsql.Select<TwoTablePartitionBy_User>()
.WithTempQuery(a => new { UserId = a.Id, a.Nickname })
.From<TwoTablePartitionBy_UserExt>()
.InnerJoin((a, b) => a.UserId == b.UserId)
.WithTempQuery((a, b) => new
{
User = a,
UserExt = b,
rownum = SqlExt.RowNumber().Over().PartitionBy(a.Nickname).OrderBy(a.UserId).ToValue()
})
.Where(a => a.rownum == 1)
.ToSql();
var assertSql17 = @"SELECT *
FROM (
SELECT a.[UserId], a.[Nickname], b.[UserId] [UserId2], b.[Remark], row_number() over( partition by a.[Nickname] order by a.[UserId]) [rownum]
FROM (
SELECT a.[Id] [UserId], a.[Nickname]
FROM [TwoTablePartitionBy_User] a ) a
INNER JOIN [TwoTablePartitionBy_UserExt] b ON a.[UserId] = b.[UserId] ) a
WHERE (a.[rownum] = 1)";
Assert.Equal(sql17, assertSql17);
var list17 = fsql.Select<TwoTablePartitionBy_User>()
.WithTempQuery(a => new { UserId = a.Id, a.Nickname })
.From<TwoTablePartitionBy_UserExt>()
.InnerJoin((a, b) => a.UserId == b.UserId)
.WithTempQuery((a, b) => new
{
User = a,
UserExt = b,
rownum = SqlExt.RowNumber().Over().PartitionBy(a.Nickname).OrderBy(a.UserId).ToValue()
})
.Where(a => a.rownum == 1)
.ToList();
var sql18 = fsql.Select<TwoTablePartitionBy_User>()
.WithTempQuery(a => new { UserId = a.Id, a.Nickname })
.From<TwoTablePartitionBy_UserExt>()
.InnerJoin((a, b) => a.UserId == b.UserId)
.WithTempQuery((a, b) => new
{
User = a,
UserExt = b,
rownum = SqlExt.RowNumber().Over().PartitionBy(a.Nickname).OrderBy(a.UserId).ToValue()
})
.Where(a => a.rownum == 1 && a.UserExt.UserId > 0 && a.User.UserId > 0)
.WithTempQuery(a => new
{
Item = a,
a.User,
a.UserExt,
a.rownum
})
.Where(a => a.rownum == 1 && a.UserExt.UserId > 0 && a.User.UserId > 0)
.Where(a => a.Item.UserExt.UserId > 0 && a.Item.User.UserId > 0)
.ToSql();
var assertSql18 = @"SELECT *
FROM (
SELECT a.[UserId], a.[Nickname], a.[UserId2], a.[Remark], a.[rownum], a.[UserId] [UserId3], a.[Nickname] [Nickname2], a.[UserId2] [UserId22], a.[Remark] [Remark2], a.[rownum] [rownum2]
FROM (
SELECT a.[UserId], a.[Nickname], b.[UserId] [UserId2], b.[Remark], row_number() over( partition by a.[Nickname] order by a.[UserId]) [rownum]
FROM (
SELECT a.[Id] [UserId], a.[Nickname]
FROM [TwoTablePartitionBy_User] a ) a
INNER JOIN [TwoTablePartitionBy_UserExt] b ON a.[UserId] = b.[UserId] ) a
WHERE (a.[rownum] = 1 AND a.[UserId2] > 0 AND a.[UserId] > 0) ) a
WHERE (a.[rownum2] = 1 AND a.[UserId22] > 0 AND a.[UserId3] > 0) AND (a.[UserId2] > 0 AND a.[UserId] > 0)";
Assert.Equal(sql18, assertSql18);
var list18 = fsql.Select<TwoTablePartitionBy_User>()
.WithTempQuery(a => new { UserId = a.Id, a.Nickname })
.From<TwoTablePartitionBy_UserExt>()
.InnerJoin((a, b) => a.UserId == b.UserId)
.WithTempQuery((a, b) => new
{
User = a,
UserExt = b,
rownum = SqlExt.RowNumber().Over().PartitionBy(a.Nickname).OrderBy(a.UserId).ToValue()
})
.Where(a => a.rownum == 1 && a.UserExt.UserId > 0 && a.User.UserId > 0)
.WithTempQuery(a => new
{
Item = a,
a.User,
a.UserExt,
a.rownum
})
.Where(a => a.rownum == 1 && a.UserExt.UserId > 0 && a.User.UserId > 0)
.Where(a => a.Item.UserExt.UserId > 0 && a.Item.User.UserId > 0)
.ToList();
} }
class TwoTablePartitionBy_User class TwoTablePartitionBy_User
{ {

View File

@ -601,12 +601,12 @@ namespace FreeSql.Tests
.UseMonitorCommand(a => Trace.WriteLine(a.CommandText)) .UseMonitorCommand(a => Trace.WriteLine(a.CommandText))
.Build(); .Build();
var data = fsql.Select<Post>().ToList(r => new //var data = fsql.Select<Post>().ToList(r => new
{ //{
Id = r.Id, // Id = r.Id,
Name = r.AuthorId.ToString(), // Name = r.AuthorId.ToString(),
AuthorName = r.Author.Name, // AuthorName = r.Author.Name,
}); //});
//g.mysql.Aop.AuditValue += (s, e) => //g.mysql.Aop.AuditValue += (s, e) =>
//{ //{

View File

@ -158,9 +158,9 @@ public class g
public static IFreeSql shentong => shentongLazy.Value; public static IFreeSql shentong => shentongLazy.Value;
static Lazy<IFreeSql> kingbaseESLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder() static Lazy<IFreeSql> kingbaseESLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.KingbaseES, "Server=127.0.0.1;Port=54321;UID=USER2;PWD=123456789;database=TDB2") //.UseConnectionString(FreeSql.DataType.KingbaseES, "Server=127.0.0.1;Port=54321;UID=USER2;PWD=123456789;database=TDB2")
//.UseConnectionFactory(FreeSql.DataType.KingbaseES, () => new Kdbndp.KdbndpConnection("Server=127.0.0.1;Port=54321;UID=USER2;PWD=123456789;database=TDB2")) .UseConnectionFactory(FreeSql.DataType.KingbaseES, () => new Kdbndp.KdbndpConnection("Server=127.0.0.1;Port=54321;UID=USER2;PWD=123456789;database=TDB2"))
.UseAutoSyncStructure(true) //.UseAutoSyncStructure(true)
.UseLazyLoading(true) .UseLazyLoading(true)
.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper) .UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
.UseNoneCommandParameter(true) .UseNoneCommandParameter(true)

View File

@ -51,6 +51,7 @@ namespace FreeSql.Internal
} }
internal bool EndsWithDbNestedField(string dbField, string dbNestedField) internal bool EndsWithDbNestedField(string dbField, string dbNestedField)
{ {
if (string.IsNullOrWhiteSpace(dbNestedField)) return true;
switch (_ado.DataType) switch (_ado.DataType)
{ {
case DataType.SqlServer: case DataType.SqlServer:
@ -161,9 +162,8 @@ namespace FreeSql.Internal
foreach (var child in parent.GetAllChilds()) foreach (var child in parent.GetAllChilds())
{ {
if (withTempQueryParser != null) if (withTempQueryParser != null)
field.Append(", ").Append(withTempQueryParser.ParseExpMatchedTable.Alias).Append(".").Append(child.DbNestedField); child.DbField = $"{withTempQueryParser.ParseExpMatchedTable.Alias}.{child.DbNestedField}";
else field.Append(", ").Append(child.DbField);
field.Append(", ").Append(child.DbField);
if (index >= 0) if (index >= 0)
{ {
child.DbNestedField = $"as{++index}"; child.DbNestedField = $"as{++index}";

View File

@ -192,6 +192,31 @@ namespace FreeSql.Internal.CommonProvider
} }
InsideField = field.Length > 0 ? field.Remove(0, 2).ToString() : null; InsideField = field.Length > 0 ? field.Remove(0, 2).ToString() : null;
InsideAf = new ReadAnonymousTypeAfInfo(InsideMap, "*"); InsideAf = new ReadAnonymousTypeAfInfo(InsideMap, "*");
field.Clear();
if (InsideMap.Childs.Where(a => a.Childs.Count > 1).Count() > 1)
{
var childs = InsideMap.GetAllChilds();
var duplicateNames = childs.GroupBy(a => a.DbNestedField).Where(a => a.Count() > 1).ToList();
if (duplicateNames.Count > 0)
{
foreach (var duplicateName in duplicateNames)
{
var dupmapIdx = 0;
foreach (var dupmap in duplicateName)
{
if (++dupmapIdx == 1) continue;
var newfield = insideSelect._commonUtils.TrimQuoteSqlName(dupmap.DbNestedField);
while (InsideField.Contains($"{newfield}{dupmapIdx}"))
++dupmapIdx;
dupmap.DbNestedField = insideSelect._commonUtils.QuoteSqlName($"{newfield}{dupmapIdx}");
}
}
foreach (var child in childs)
field.Append(", ").Append(child.DbField).Append(InsideSelect._commonExpression.EndsWithDbNestedField(child.DbField, child.DbNestedField) ? "" : InsideSelect._commonUtils.FieldAsAlias(child.DbNestedField));
InsideField = field.Length > 0 ? field.Remove(0, 2).ToString() : null;
field.Clear();
}
}
} }
} }
@ -1208,6 +1233,11 @@ namespace FreeSql.Internal.CommonProvider
ret._cancel = _cancel; ret._cancel = _cancel;
ret._params.AddRange(_params); ret._params.AddRange(_params);
if (ret._tables[0].Table == null) ret._tables[0].Table = TableInfo.GetDefaultTable(typeof(TDto)); if (ret._tables[0].Table == null) ret._tables[0].Table = TableInfo.GetDefaultTable(typeof(TDto));
if (selector is LambdaExpression lambdaExp && lambdaExp != null)
{
for (var a = 0; a < lambdaExp.Parameters.Count; a++)
_tables[a].Parameter = lambdaExp.Parameters[a];
}
var parser = new WithTempQueryParser(this, null, selector, ret._tables[0]); var parser = new WithTempQueryParser(this, null, selector, ret._tables[0]);
var sql = $"\r\n{this.ToSql(parser._insideSelectList[0].InsideField)}"; var sql = $"\r\n{this.ToSql(parser._insideSelectList[0].InsideField)}";
ret.WithSql(sql); ret.WithSql(sql);

View File

@ -247,6 +247,7 @@ namespace FreeSql.Internal.CommonProvider
_addFieldAlias = true; //解决:[Column(Name = "flevel") 与属性名不一致时,嵌套查询 bug _addFieldAlias = true; //解决:[Column(Name = "flevel") 与属性名不一致时,嵌套查询 bug
var old_field = _field; var old_field = _field;
var fieldsb = new StringBuilder(); var fieldsb = new StringBuilder();
if (_map.Childs.Any() == false) fieldsb.Append(", ").Append(_map.DbField).Append(_comonExp.EndsWithDbNestedField(_map.DbField, _map.DbNestedField) ? "" : _comonExp._common.FieldAsAlias(_map.DbNestedField));
foreach (var child in _map.GetAllChilds()) foreach (var child in _map.GetAllChilds())
fieldsb.Append(", ").Append(child.DbField).Append(_comonExp.EndsWithDbNestedField(child.DbField, child.DbNestedField) ? "" : _comonExp._common.FieldAsAlias(child.DbNestedField)); fieldsb.Append(", ").Append(child.DbField).Append(_comonExp.EndsWithDbNestedField(child.DbField, child.DbNestedField) ? "" : _comonExp._common.FieldAsAlias(child.DbNestedField));
_field = fieldsb.ToString(); _field = fieldsb.ToString();

View File

@ -2459,9 +2459,9 @@ namespace FreeSql.Internal
} }
break; break;
} }
if (startLength > 0) if (startLength >= 0)
{ {
var pvalue = sql.Substring(startIdx, startLength).Replace("''", "'"); var pvalue = startLength == 0 ? "" : sql.Substring(startIdx, startLength).Replace("''", "'");
var pname = parms.Where(a => a.Value == pvalue).Select(a => a.Key).FirstOrDefault(); var pname = parms.Where(a => a.Value == pvalue).Select(a => a.Key).FirstOrDefault();
if (string.IsNullOrEmpty(pname)) if (string.IsNullOrEmpty(pname))
{ {

View File

@ -44,9 +44,7 @@ QQ群4336577(已满)、8578575(已满)、52508226(在线)
- [zhontai.net Admin 后台管理系统](https://github.com/zhontai/Admin.Core) - [zhontai.net Admin 后台管理系统](https://github.com/zhontai/Admin.Core)
- [A simple and practical CMS implemented by .NET Core](https://github.com/luoyunchong/lin-cms-dotnetcore) - [A simple and practical CMS implemented by .NET Core](https://github.com/luoyunchong/lin-cms-dotnetcore)
- [iusaas.com SaaS 企业应用管理系统](https://github.com/alonsoalon/TenantSite.Server)
- [EasyCms 企业建站事业单位使用的CMS管理系统](https://github.com/jasonyush/EasyCMS) - [EasyCms 企业建站事业单位使用的CMS管理系统](https://github.com/jasonyush/EasyCMS)
- [内容管理系统](https://github.com/hejiyong/fscms)
<p align="center"> <p align="center">
<img src="https://github.com/dotnetcore/FreeSql/raw/master/functions13.png"/> <img src="https://github.com/dotnetcore/FreeSql/raw/master/functions13.png"/>