mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
v0.0.11 修复IAdo.Query直接查询sql的bug
This commit is contained in:
parent
7e59e07956
commit
74df67fc13
@ -191,7 +191,7 @@ namespace FreeSql.Tests.PerformanceTest {
|
||||
class xxx {
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Url { get; set; }
|
||||
//public string Url { get; set; }
|
||||
public DateTime Create_time { get; set; }
|
||||
public bool Is_deleted { get; set; }
|
||||
}
|
||||
|
@ -17,10 +17,7 @@ namespace FreeSql.Tests.MySql {
|
||||
public int Id { get; set; }
|
||||
public int Clicks { get; set; }
|
||||
public int TestTypeInfoGuid { get; set; }
|
||||
public virtual TestTypeInfo TestTypeInfo { get; set; }
|
||||
|
||||
public int TypeGuid { get; set; }
|
||||
public virtual TestTypeInfo Type { get; set; }
|
||||
public TestTypeInfo Type { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
@ -38,9 +35,6 @@ namespace FreeSql.Tests.MySql {
|
||||
public int ParentId { get; set; }
|
||||
public virtual TestTypeParentInfo Parent { get; set; }
|
||||
|
||||
public int SelfGuid { get; set; }
|
||||
public virtual TestTypeInfo Self { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public virtual ICollection<Topic> Topics { get; set; }
|
||||
@ -91,12 +85,7 @@ namespace FreeSql.Tests.MySql {
|
||||
|
||||
var songs = g.mysql.Select<Song>().Limit(10).ToList();
|
||||
|
||||
var ts = g.mysql.Select<TestTypeInfo>(1).ToOne();
|
||||
|
||||
|
||||
Topic t = g.mysql.Select<Topic>(2).ToOne();
|
||||
Topic tz = g.mysql.Select<Topic>(2).ToOne();
|
||||
var tzType = tz.Type;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -452,28 +441,28 @@ namespace FreeSql.Tests.MySql {
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`)", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<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.TestTypeInfoGuid && b.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Guid` = a.`TestTypeInfoGuid` AND b.`Name` = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo>((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Name` = 'typeTitle' AND b.`Guid` = a.`TestTypeInfoGuid`)", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` b WHERE (b.`Name` = 'typeTitle' AND b.`Guid` = a.`TestTypeInfoGuid`)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo, TestTypeParentInfo>((a, b, c) => c.Name == "tparent");
|
||||
@ -486,7 +475,7 @@ namespace FreeSql.Tests.MySql {
|
||||
.Where(a => a.Id == 10 && c.Name == "xxx")
|
||||
.Where(a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
@ -515,17 +504,17 @@ namespace FreeSql.Tests.MySql {
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`)", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type WHERE (a__Type.`Name` = 'typeTitle' AND a__Type.`Guid` = a.`TestTypeInfoGuid`)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a__Type.`Guid`, a__Type.`ParentId`, a__Type.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeInfo` a__Type, `TestTypeParentInfo` a__Type__Parent WHERE (a__Type__Parent.`Name` = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@ -533,7 +522,7 @@ namespace FreeSql.Tests.MySql {
|
||||
.WhereIf(true, a => a.Id == 10 && c.Name == "xxx")
|
||||
.WhereIf(true, a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, b.`Guid`, b.`ParentId`, b.`Name`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql);
|
||||
Assert.Equal("SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime` FROM `tb_topic` a, `TestTypeParentInfo` c, `TestTypeInfo` b WHERE (a.`Id` = 10 AND c.`Name` = 'xxx') AND (b.`ParentId` = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
|
@ -305,28 +305,28 @@ namespace FreeSql.Tests.Oracle {
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<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.TestTypeInfoGuid && b.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo>((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Name\" = 'typeTitle' AND b.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Name\" = 'typeTitle' AND b.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo, TestTypeParentInfo>((a, b, c) => c.Name == "tparent");
|
||||
@ -339,7 +339,7 @@ namespace FreeSql.Tests.Oracle {
|
||||
.Where(a => a.Id == 10 && c.Name == "xxx")
|
||||
.Where(a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
@ -368,17 +368,17 @@ namespace FreeSql.Tests.Oracle {
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@ -386,7 +386,7 @@ namespace FreeSql.Tests.Oracle {
|
||||
.WhereIf(true, a => a.Id == 10 && c.Name == "xxx")
|
||||
.WhereIf(true, a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
|
@ -382,28 +382,28 @@ namespace FreeSql.Tests.PostgreSQL {
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle' AND a__Type.\"guid\" = a.\"testtypeinfoguid\")", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle' AND a__Type.\"guid\" = a.\"testtypeinfoguid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type, \"testtypeparentinfo\" a__Type__Parent WHERE (a__Type__Parent.\"name\" = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type, \"testtypeparentinfo\" a__Type__Parent WHERE (a__Type__Parent.\"name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<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.TestTypeInfoGuid && b.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" b WHERE (b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" b WHERE (b.\"guid\" = a.\"testtypeinfoguid\" AND b.\"name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo>((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" b WHERE (b.\"name\" = 'typeTitle' AND b.\"guid\" = a.\"testtypeinfoguid\")", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" b WHERE (b.\"name\" = 'typeTitle' AND b.\"guid\" = a.\"testtypeinfoguid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo, TestTypeParentInfo>((a, b, c) => c.Name == "tparent");
|
||||
@ -416,7 +416,7 @@ namespace FreeSql.Tests.PostgreSQL {
|
||||
.Where(a => a.Id == 10 && c.Name == "xxx")
|
||||
.Where(a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c, \"testtypeinfo\" b WHERE (a.\"id\" = 10 AND c.\"name\" = 'xxx') AND (b.\"parentid\" = 20)", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c, \"testtypeinfo\" b WHERE (a.\"id\" = 10 AND c.\"name\" = 'xxx') AND (b.\"parentid\" = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
@ -445,17 +445,17 @@ namespace FreeSql.Tests.PostgreSQL {
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle' AND a__Type.\"guid\" = a.\"testtypeinfoguid\")", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type WHERE (a__Type.\"name\" = 'typeTitle' AND a__Type.\"guid\" = a.\"testtypeinfoguid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a__Type.\"guid\", a__Type.\"parentid\", a__Type.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type, \"testtypeparentinfo\" a__Type__Parent WHERE (a__Type__Parent.\"name\" = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeinfo\" a__Type, \"testtypeparentinfo\" a__Type__Parent WHERE (a__Type__Parent.\"name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@ -463,7 +463,7 @@ namespace FreeSql.Tests.PostgreSQL {
|
||||
.WhereIf(true, a => a.Id == 10 && c.Name == "xxx")
|
||||
.WhereIf(true, a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", b.\"guid\", b.\"parentid\", b.\"name\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c, \"testtypeinfo\" b WHERE (a.\"id\" = 10 AND c.\"name\" = 'xxx') AND (b.\"parentid\" = 20)", sql);
|
||||
Assert.Equal("SELECT a.\"id\", a.\"clicks\", a.\"testtypeinfoguid\", a.\"title\", a.\"createtime\" FROM \"tb_topic\" a, \"testtypeparentinfo\" c, \"testtypeinfo\" b WHERE (a.\"id\" = 10 AND c.\"name\" = 'xxx') AND (b.\"parentid\" = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
|
@ -305,28 +305,28 @@ namespace FreeSql.Tests.SqlServer {
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle' AND a__Type.[Guid] = a.[TestTypeInfoGuid])", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle' AND a__Type.[Guid] = a.[TestTypeInfoGuid])", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type, [TestTypeParentInfo] a__Type__Parent WHERE (a__Type__Parent.[Name] = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type, [TestTypeParentInfo] a__Type__Parent WHERE (a__Type__Parent.[Name] = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<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.TestTypeInfoGuid && b.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] b WHERE (b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] b WHERE (b.[Guid] = a.[TestTypeInfoGuid] AND b.[Name] = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo>((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] b WHERE (b.[Name] = 'typeTitle' AND b.[Guid] = a.[TestTypeInfoGuid])", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] b WHERE (b.[Name] = 'typeTitle' AND b.[Guid] = a.[TestTypeInfoGuid])", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo, TestTypeParentInfo>((a, b, c) => c.Name == "tparent");
|
||||
@ -339,7 +339,7 @@ namespace FreeSql.Tests.SqlServer {
|
||||
.Where(a => a.Id == 10 && c.Name == "xxx")
|
||||
.Where(a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c, [TestTypeInfo] b WHERE (a.[Id] = 10 AND c.[Name] = 'xxx') AND (b.[ParentId] = 20)", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c, [TestTypeInfo] b WHERE (a.[Id] = 10 AND c.[Name] = 'xxx') AND (b.[ParentId] = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
@ -368,17 +368,17 @@ namespace FreeSql.Tests.SqlServer {
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle' AND a__Type.[Guid] = a.[TestTypeInfoGuid])", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type WHERE (a__Type.[Name] = 'typeTitle' AND a__Type.[Guid] = a.[TestTypeInfoGuid])", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a__Type.[Guid], a__Type.[ParentId], a__Type.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type, [TestTypeParentInfo] a__Type__Parent WHERE (a__Type__Parent.[Name] = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeInfo] a__Type, [TestTypeParentInfo] a__Type__Parent WHERE (a__Type__Parent.[Name] = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@ -386,7 +386,7 @@ namespace FreeSql.Tests.SqlServer {
|
||||
.WhereIf(true, a => a.Id == 10 && c.Name == "xxx")
|
||||
.WhereIf(true, a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], b.[Guid], b.[ParentId], b.[Name], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c, [TestTypeInfo] b WHERE (a.[Id] = 10 AND c.[Name] = 'xxx') AND (b.[ParentId] = 20)", sql);
|
||||
Assert.Equal("SELECT a.[Id], a.[Clicks], a.[TestTypeInfoGuid], a.[Title], a.[CreateTime] FROM [tb_topic22] a, [TestTypeParentInfo] c, [TestTypeInfo] b WHERE (a.[Id] = 10 AND c.[Name] = 'xxx') AND (b.[ParentId] = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
|
@ -305,28 +305,28 @@ namespace FreeSql.Tests.Sqlite {
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<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.TestTypeInfoGuid && b.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo>((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Name\" = 'typeTitle' AND b.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Name\" = 'typeTitle' AND b.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo, TestTypeParentInfo>((a, b, c) => c.Name == "tparent");
|
||||
@ -339,7 +339,7 @@ namespace FreeSql.Tests.Sqlite {
|
||||
.Where(a => a.Id == 10 && c.Name == "xxx")
|
||||
.Where(a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
@ -368,17 +368,17 @@ namespace FreeSql.Tests.Sqlite {
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@ -386,7 +386,7 @@ namespace FreeSql.Tests.Sqlite {
|
||||
.WhereIf(true, a => a.Id == 10 && c.Name == "xxx")
|
||||
.WhereIf(true, a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
|
@ -13,19 +13,19 @@ public static class FreeSqlGlobalExtensions {
|
||||
public static FreeSql.ISelect<T> Queryable<T>(this IFreeSql freesql) where T : class => freesql.Select<T>();
|
||||
|
||||
static Lazy<Dictionary<Type, bool>> dicIsNumberType = new Lazy<Dictionary<Type, bool>>(() => new Dictionary<Type, bool> {
|
||||
[typeof(sbyte)] = true,
|
||||
[typeof(short)] = true,
|
||||
[typeof(int)] = true,
|
||||
[typeof(long)] = true,
|
||||
[typeof(byte)] = true,
|
||||
[typeof(ushort)] = true,
|
||||
[typeof(uint)] = true,
|
||||
[typeof(ulong)] = true,
|
||||
[typeof(double)] = true,
|
||||
[typeof(float)] = true,
|
||||
[typeof(decimal)] = true
|
||||
[typeof(sbyte)] = true, [typeof(sbyte?)] = true,
|
||||
[typeof(short)] = true, [typeof(short?)] = true,
|
||||
[typeof(int)] = true, [typeof(int?)] = true,
|
||||
[typeof(long)] = true, [typeof(long?)] = true,
|
||||
[typeof(byte)] = true, [typeof(byte?)] = true,
|
||||
[typeof(ushort)] = true, [typeof(ushort?)] = true,
|
||||
[typeof(uint)] = true, [typeof(uint?)] = true,
|
||||
[typeof(ulong)] = true, [typeof(ulong?)] = true,
|
||||
[typeof(double)] = true, [typeof(double?)] = true,
|
||||
[typeof(float)] = true, [typeof(float?)] = true,
|
||||
[typeof(decimal)] = true, [typeof(decimal?)] = true
|
||||
});
|
||||
public static bool IsNumberType(this Type that) => that == null ? false : dicIsNumberType.Value.ContainsKey(that.GenericTypeArguments.FirstOrDefault() ?? that);
|
||||
public static bool IsNumberType(this Type that) => that == null ? false : dicIsNumberType.Value.ContainsKey(that);
|
||||
|
||||
/// <summary>
|
||||
/// 测量两个经纬度的距离,返回单位:米
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Version>0.0.9</Version>
|
||||
<Version>0.0.11</Version>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>YeXiangQin</Authors>
|
||||
<Description>打造 .NETCore 最方便的 ORM,DbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
|
||||
|
@ -64,19 +64,19 @@ namespace FreeSql.Internal.CommonProvider {
|
||||
if (isThrowException) throw e;
|
||||
}
|
||||
|
||||
internal static ConcurrentDictionary<Type, Dictionary<string, PropertyInfo>> dicQueryTypeGetProperties = new ConcurrentDictionary<Type, Dictionary<string, PropertyInfo>>();
|
||||
internal static ConcurrentDictionary<Type, PropertyInfo[]> dicQueryTypeGetProperties = new ConcurrentDictionary<Type, PropertyInfo[]>();
|
||||
public List<T> Query<T>(string cmdText, object parms = null) => Query<T>(CommandType.Text, cmdText, GetDbParamtersByObject(cmdText, parms));
|
||||
public List<T> Query<T>(CommandType cmdType, string cmdText, params DbParameter[] cmdParms) {
|
||||
var ret = new List<T>();
|
||||
var type = typeof(T);
|
||||
int[] indexes = null;
|
||||
var props = dicQueryTypeGetProperties.GetOrAdd(type, k => type.GetProperties().ToDictionary(a => a.Name, a => a, StringComparer.CurrentCultureIgnoreCase));
|
||||
var props = dicQueryTypeGetProperties.GetOrAdd(type, k => type.GetProperties());
|
||||
ExecuteReader(dr => {
|
||||
if (indexes == null) {
|
||||
var idxs = new List<int>();
|
||||
var dic = new Dictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||
for (var a = 0; a < dr.FieldCount; a++)
|
||||
if (props.ContainsKey(dr.GetName(a))) idxs.Add(a);
|
||||
indexes = idxs.ToArray();
|
||||
dic.Add(dr.GetName(a), a);
|
||||
indexes = props.Select(a => dic.TryGetValue(a.Name, out var tryint) ? tryint : -1).ToArray();
|
||||
}
|
||||
ret.Add((T)Utils.ExecuteArrayRowReadClassOrTuple(type, indexes, dr, 0).Value);
|
||||
}, cmdType, cmdText, cmdParms);
|
||||
|
@ -14,13 +14,13 @@ namespace FreeSql.Internal.CommonProvider {
|
||||
var ret = new List<T>();
|
||||
var type = typeof(T);
|
||||
int[] indexes = null;
|
||||
var props = dicQueryTypeGetProperties.GetOrAdd(type, k => type.GetProperties().ToDictionary(a => a.Name, a => a, StringComparer.CurrentCultureIgnoreCase));
|
||||
var props = dicQueryTypeGetProperties.GetOrAdd(type, k => type.GetProperties());
|
||||
await ExecuteReaderAsync(dr => {
|
||||
if (indexes == null) {
|
||||
var idxs = new List<int>();
|
||||
var dic = new Dictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||
for (var a = 0; a < dr.FieldCount; a++)
|
||||
if (props.ContainsKey(dr.GetName(a))) idxs.Add(a);
|
||||
indexes = idxs.ToArray();
|
||||
dic.Add(dr.GetName(a), a);
|
||||
indexes = props.Select(a => dic.TryGetValue(a.Name, out var tryint) ? tryint : -1).ToArray();
|
||||
}
|
||||
ret.Add((T)Utils.ExecuteArrayRowReadClassOrTuple(type, indexes, dr, 0).Value);
|
||||
return Task.CompletedTask;
|
||||
|
@ -249,7 +249,7 @@ namespace FreeSql.Internal.CommonProvider {
|
||||
public Func<DbDataReader, T1> Read { get; set; }
|
||||
}
|
||||
protected GetAllFieldExpressionTreeInfo GetAllFieldExpressionTree() {
|
||||
return _dicGetAllFieldExpressionTree.GetOrAdd(string.Join("+", _tables.Select(a => $"{a.Table.DbName}-{a.Alias}")), s => {
|
||||
return _dicGetAllFieldExpressionTree.GetOrAdd(string.Join("+", _tables.Select(a => $"{a.Table.DbName}-{a.Alias}-{a.Type}")), s => {
|
||||
var tb1 = _tables.First().Table;
|
||||
var type = tb1.TypeLazy ?? tb1.Type;
|
||||
var props = tb1.Properties;
|
||||
|
@ -121,9 +121,10 @@ namespace FreeSql.Internal {
|
||||
.AppendLine("using FreeSql.DataAnnotations;")
|
||||
.AppendLine("using System.Collections.Generic;")
|
||||
.AppendLine("using System.Linq;")
|
||||
.AppendLine("")
|
||||
.AppendLine("using Newtonsoft.Json;")
|
||||
.AppendLine()
|
||||
.Append("public class ").Append(trytbTypeLazyName).Append(" : ").Append(trytbTypeName).AppendLine(" {")
|
||||
.AppendLine(" public IFreeSql __fsql_orm__ { get; set; }\r\n");
|
||||
.AppendLine(" [JsonIgnore] public IFreeSql __fsql_orm__ { get; set; }\r\n");
|
||||
|
||||
foreach (var vp in propsLazy) {
|
||||
var propTypeName = vp.Item1.PropertyType.IsGenericType ?
|
||||
@ -708,6 +709,7 @@ namespace FreeSql.Internal {
|
||||
Expression.Add(tryidxExp, Expression.Constant(1))
|
||||
);
|
||||
else {
|
||||
++propIndex;
|
||||
continue;
|
||||
//readExpAssign = Expression.Call(MethodExecuteArrayRowReadClassOrTuple, new Expression[] { Expression.Constant(prop.PropertyType), indexesExp, rowExp, tryidxExp });
|
||||
}
|
||||
@ -719,12 +721,18 @@ namespace FreeSql.Internal {
|
||||
Expression.Assign(tryidxExp, Expression.ArrayAccess(indexesExp, Expression.Constant(propIndex))),
|
||||
Expression.Assign(tryidxExp, dataIndexExp)
|
||||
),
|
||||
Expression.IfThen(
|
||||
Expression.GreaterThanOrEqual(tryidxExp, Expression.Constant(0)),
|
||||
Expression.Block(
|
||||
Expression.Assign(readExp, readExpAssign),
|
||||
Expression.IfThen(Expression.GreaterThan(readExpDataIndex, dataIndexExp),
|
||||
Expression.Assign(dataIndexExp, readExpDataIndex)),
|
||||
Expression.IfThenElse(Expression.Equal(readExpValue, Expression.Constant(null)),
|
||||
Expression.IfThenElse(
|
||||
Expression.Equal(readExpValue, Expression.Constant(null)),
|
||||
Expression.Call(retExp, propGetSetMethod, Expression.Default(prop.PropertyType)),
|
||||
Expression.Call(retExp, propGetSetMethod, Expression.Convert(readExpValue, prop.PropertyType)))
|
||||
)
|
||||
)
|
||||
});
|
||||
++propIndex;
|
||||
}
|
||||
|
@ -253,12 +253,14 @@ where a.table_schema in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?
|
||||
}
|
||||
}
|
||||
|
||||
static object syncStructureLock = new object();
|
||||
ConcurrentDictionary<string, bool> dicSyced = new ConcurrentDictionary<string, bool>();
|
||||
public bool SyncStructure<TEntity>() => this.SyncStructure(typeof(TEntity));
|
||||
public bool SyncStructure(params Type[] entityTypes) {
|
||||
if (entityTypes == null) return true;
|
||||
var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a.FullName) == false).ToArray();
|
||||
if (syncTypes.Any() == false) return true;
|
||||
lock (syncStructureLock) {
|
||||
var ddl = this.GetComparisonDDLStatements(syncTypes);
|
||||
if (string.IsNullOrEmpty(ddl)) {
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
@ -268,6 +270,7 @@ where a.table_schema in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
return affrows > 0;
|
||||
}
|
||||
}
|
||||
public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
|
||||
}
|
||||
}
|
@ -291,12 +291,14 @@ where owner={{0}} and table_name={{1}}".FormatOracleSQL(tboldname ?? tbname);
|
||||
return sb.Length == 0 ? null : sb.Insert(0, "BEGIN \r\n").Insert(0, sbDeclare.ToString()).Append("END;").ToString();
|
||||
}
|
||||
|
||||
static object syncStructureLock = new object();
|
||||
ConcurrentDictionary<string, bool> dicSyced = new ConcurrentDictionary<string, bool>();
|
||||
public bool SyncStructure<TEntity>() => this.SyncStructure(typeof(TEntity));
|
||||
public bool SyncStructure(params Type[] entityTypes) {
|
||||
if (entityTypes == null) return true;
|
||||
var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a.FullName) == false).ToArray();
|
||||
if (syncTypes.Any() == false) return true;
|
||||
lock (syncStructureLock) {
|
||||
var ddl = this.GetComparisonDDLStatements(syncTypes);
|
||||
if (string.IsNullOrEmpty(ddl)) {
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
@ -306,6 +308,7 @@ where owner={{0}} and table_name={{1}}".FormatOracleSQL(tboldname ?? tbname);
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
return affrows > 0;
|
||||
}
|
||||
}
|
||||
public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
|
||||
}
|
||||
}
|
@ -305,12 +305,14 @@ where pg_namespace.nspname={0} and pg_class.relname={1} and pg_constraint.contyp
|
||||
return sb.Length == 0 ? null : sb.ToString();
|
||||
}
|
||||
|
||||
static object syncStructureLock = new object();
|
||||
ConcurrentDictionary<string, bool> dicSyced = new ConcurrentDictionary<string, bool>();
|
||||
public bool SyncStructure<TEntity>() => this.SyncStructure(typeof(TEntity));
|
||||
public bool SyncStructure(params Type[] entityTypes) {
|
||||
if (entityTypes == null) return true;
|
||||
var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a.FullName) == false).ToArray();
|
||||
if (syncTypes.Any() == false) return true;
|
||||
lock (syncStructureLock) {
|
||||
var ddl = this.GetComparisonDDLStatements(syncTypes);
|
||||
if (string.IsNullOrEmpty(ddl)) {
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
@ -320,6 +322,7 @@ where pg_namespace.nspname={0} and pg_class.relname={1} and pg_constraint.contyp
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
return affrows > 0;
|
||||
}
|
||||
}
|
||||
public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
|
||||
}
|
||||
}
|
@ -263,12 +263,14 @@ use " + database, tboldname ?? tbname);
|
||||
}
|
||||
}
|
||||
|
||||
static object syncStructureLock = new object();
|
||||
ConcurrentDictionary<string, bool> dicSyced = new ConcurrentDictionary<string, bool>();
|
||||
public bool SyncStructure<TEntity>() => this.SyncStructure(typeof(TEntity));
|
||||
public bool SyncStructure(params Type[] entityTypes) {
|
||||
if (entityTypes == null) return true;
|
||||
var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a.FullName) == false).ToArray();
|
||||
if (syncTypes.Any() == false) return true;
|
||||
lock (syncStructureLock) {
|
||||
var ddl = this.GetComparisonDDLStatements(syncTypes);
|
||||
if (string.IsNullOrEmpty(ddl)) {
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
@ -278,6 +280,7 @@ use " + database, tboldname ?? tbname);
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
return affrows > 0;
|
||||
}
|
||||
}
|
||||
public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
|
||||
}
|
||||
}
|
@ -221,12 +221,14 @@ namespace FreeSql.Sqlite {
|
||||
return sb.Length == 0 ? null : sb.ToString();
|
||||
}
|
||||
|
||||
static object syncStructureLock = new object();
|
||||
ConcurrentDictionary<string, bool> dicSyced = new ConcurrentDictionary<string, bool>();
|
||||
public bool SyncStructure<TEntity>() => this.SyncStructure(typeof(TEntity));
|
||||
public bool SyncStructure(params Type[] entityTypes) {
|
||||
if (entityTypes == null) return true;
|
||||
var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a.FullName) == false).ToArray();
|
||||
if (syncTypes.Any() == false) return true;
|
||||
lock (syncStructureLock) {
|
||||
var ddl = this.GetComparisonDDLStatements(syncTypes);
|
||||
if (string.IsNullOrEmpty(ddl)) {
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
@ -236,6 +238,7 @@ namespace FreeSql.Sqlite {
|
||||
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
|
||||
return affrows > 0;
|
||||
}
|
||||
}
|
||||
public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user