mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 修复 GroupBy 类型转换错误;#186
- 修复 .ToList(a => new DTO(a.id)) 报 未将对象引用设置到对象的实例 问题; #187 - 修复 update语句,二元运算解析出错; #184
This commit is contained in:
@ -146,6 +146,19 @@ namespace FreeSql.Tests.Odbc.Dameng
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
}
|
||||
class TestDto2
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
|
||||
public TestDto2() { }
|
||||
public TestDto2(int id, string name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void ToList()
|
||||
{
|
||||
@ -160,6 +173,18 @@ namespace FreeSql.Tests.Odbc.Dameng
|
||||
var testDto33 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto { });
|
||||
var testDto44 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto() { });
|
||||
|
||||
var testDto211 = select.Limit(10).ToList(a => new TestDto2(a.Id, a.Title));
|
||||
var testDto212 = select.Limit(10).ToList(a => new TestDto2());
|
||||
var testDto213 = select.Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto214 = select.Limit(10).ToList(a => new 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 testDto2222 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2());
|
||||
var testDto2233 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto2244 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2() { });
|
||||
var testDto2255 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList<TestDto2>();
|
||||
|
||||
g.dameng.Insert<TestGuidIdToList>().AppendData(new TestGuidIdToList()).ExecuteAffrows();
|
||||
var testGuidId5 = g.dameng.Select<TestGuidIdToList>().ToList();
|
||||
var testGuidId6 = g.dameng.Select<TestGuidIdToList>().ToList(a => a.id);
|
||||
@ -662,6 +687,9 @@ namespace FreeSql.Tests.Odbc.Dameng
|
||||
var testpid1 = g.dameng.Insert<TestTypeInfo>().AppendData(new TestTypeInfo { Name = "Name" + DateTime.Now.ToString("yyyyMMddHHmmss") }).ExecuteIdentity();
|
||||
g.dameng.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)
|
||||
.ToList(a => a.Sum(a.Value.TypeGuid));
|
||||
|
||||
var aggsql1 = select
|
||||
.GroupBy(a => a.Title)
|
||||
.ToSql(b => new
|
||||
|
@ -86,6 +86,10 @@ namespace FreeSql.Tests.Odbc.Dameng
|
||||
sql = update.Set(a => a.Clicks == a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = trunc(\"CLICKS\" * 10 / 1) WHERE (\"ID\" = 1)", sql);
|
||||
|
||||
var dt2000 = DateTime.Parse("2000-01-01");
|
||||
sql = update.Set(a => a.Clicks == (a.CreateTime > dt2000 ? 1 : 2)).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = case when \"CREATETIME\" > to_timestamp('2000-01-01 00:00:00.000000','YYYY-MM-DD HH24:MI:SS.FF6') then 1 else 2 end WHERE (\"ID\" = 1)", sql);
|
||||
|
||||
sql = update.Set(a => a.Id == 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"ID\" = 10 WHERE (\"ID\" = 1)", sql);
|
||||
}
|
||||
|
@ -137,6 +137,19 @@ namespace FreeSql.Tests.Odbc.Default
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
}
|
||||
class TestDto2
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
|
||||
public TestDto2() { }
|
||||
public TestDto2(int id, string name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void ToList()
|
||||
{
|
||||
@ -151,6 +164,18 @@ namespace FreeSql.Tests.Odbc.Default
|
||||
var testDto33 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto { });
|
||||
var testDto44 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto() { });
|
||||
|
||||
var testDto211 = select.Limit(10).ToList(a => new TestDto2(a.Id, a.Title));
|
||||
var testDto212 = select.Limit(10).ToList(a => new TestDto2());
|
||||
var testDto213 = select.Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto214 = select.Limit(10).ToList(a => new 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 testDto2222 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2());
|
||||
var testDto2233 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto2244 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2() { });
|
||||
var testDto2255 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList<TestDto2>();
|
||||
|
||||
g.odbc.Insert<TestGuidIdToList>().AppendData(new TestGuidIdToList()).ExecuteAffrows();
|
||||
var testGuidId5 = g.odbc.Select<TestGuidIdToList>().ToList();
|
||||
var testGuidId6 = g.odbc.Select<TestGuidIdToList>().ToList(a => a.id);
|
||||
@ -653,6 +678,9 @@ namespace FreeSql.Tests.Odbc.Default
|
||||
var testpid1 = g.odbc.Insert<TestTypeInfo>().AppendData(new TestTypeInfo { Name = "Name" + DateTime.Now.ToString("yyyyMMddHHmmss") }).ExecuteIdentity();
|
||||
g.odbc.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)
|
||||
.ToList(a => a.Sum(a.Value.TypeGuid));
|
||||
|
||||
var aggsql1 = select
|
||||
.GroupBy(a => a.Title)
|
||||
.ToSql(b => new
|
||||
|
@ -88,6 +88,10 @@ namespace FreeSql.Tests.Odbc.Default
|
||||
sql = update.Set(a => a.Clicks == a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Clicks] = [Clicks] * 10 / 1 WHERE ([Id] = 1)", sql);
|
||||
|
||||
var dt2000 = DateTime.Parse("2000-01-01");
|
||||
sql = update.Set(a => a.Clicks == (a.CreateTime > dt2000 ? 1 : 2)).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Clicks] = case when [CreateTime] > '2000-01-01 00:00:00' then 1 else 2 end WHERE ([Id] = 1)", sql);
|
||||
|
||||
sql = update.Set(a => a.Id == 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Id] = 10 WHERE ([Id] = 1)", sql);
|
||||
}
|
||||
|
@ -155,6 +155,19 @@ namespace FreeSql.Tests.Odbc.MySql
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
}
|
||||
class TestDto2
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
|
||||
public TestDto2() { }
|
||||
public TestDto2(int id, string name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void ToList()
|
||||
{
|
||||
@ -171,6 +184,18 @@ namespace FreeSql.Tests.Odbc.MySql
|
||||
var testDto44 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto() { });
|
||||
var testDto55 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList<TestDto>();
|
||||
|
||||
var testDto211 = select.Limit(10).ToList(a => new TestDto2(a.Id, a.Title));
|
||||
var testDto212 = select.Limit(10).ToList(a => new TestDto2());
|
||||
var testDto213 = select.Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto214 = select.Limit(10).ToList(a => new 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 testDto2222 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2());
|
||||
var testDto2233 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto2244 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2() { });
|
||||
var testDto2255 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList<TestDto2>();
|
||||
|
||||
var t0 = select.Limit(50).ToList();
|
||||
|
||||
|
||||
@ -746,6 +771,9 @@ namespace FreeSql.Tests.Odbc.MySql
|
||||
var testpid1 = g.mysql.Insert<TestTypeInfo>().AppendData(new TestTypeInfo { Name = "Name" + DateTime.Now.ToString("yyyyMMddHHmmss") }).ExecuteIdentity();
|
||||
g.mysql.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)
|
||||
.ToList(a => a.Sum(a.Value.TypeGuid));
|
||||
|
||||
var aggsql1 = select
|
||||
.GroupBy(a => a.Title)
|
||||
.ToSql(b => new
|
||||
|
@ -128,6 +128,10 @@ namespace FreeSql.Tests.Odbc.MySql
|
||||
sql = update.Set(a => a.Clicks == a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE `tb_topic` SET `Clicks` = `Clicks` * 10 div 1 WHERE (`Id` = 1)", sql);
|
||||
|
||||
var dt2000 = DateTime.Parse("2000-01-01");
|
||||
sql = update.Set(a => a.Clicks == (a.CreateTime > dt2000 ? 1 : 2)).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE `tb_topic` SET `Clicks` = case when `CreateTime` > '2000-01-01 00:00:00.000' then 1 else 2 end WHERE (`Id` = 1)", sql);
|
||||
|
||||
sql = update.Set(a => a.Id == 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE `tb_topic` SET `Id` = 10 WHERE (`Id` = 1)", sql);
|
||||
|
||||
|
@ -146,6 +146,19 @@ namespace FreeSql.Tests.Odbc.Oracle
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
}
|
||||
class TestDto2
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
|
||||
public TestDto2() { }
|
||||
public TestDto2(int id, string name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void ToList()
|
||||
{
|
||||
@ -160,6 +173,18 @@ namespace FreeSql.Tests.Odbc.Oracle
|
||||
var testDto33 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto { });
|
||||
var testDto44 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto() { });
|
||||
|
||||
var testDto211 = select.Limit(10).ToList(a => new TestDto2(a.Id, a.Title));
|
||||
var testDto212 = select.Limit(10).ToList(a => new TestDto2());
|
||||
var testDto213 = select.Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto214 = select.Limit(10).ToList(a => new 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 testDto2222 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2());
|
||||
var testDto2233 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto2244 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2() { });
|
||||
var testDto2255 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList<TestDto2>();
|
||||
|
||||
g.oracle.Insert<TestGuidIdToList>().AppendData(new TestGuidIdToList()).ExecuteAffrows();
|
||||
var testGuidId5 = g.oracle.Select<TestGuidIdToList>().ToList();
|
||||
var testGuidId6 = g.oracle.Select<TestGuidIdToList>().ToList(a => a.id);
|
||||
@ -662,6 +687,9 @@ namespace FreeSql.Tests.Odbc.Oracle
|
||||
var testpid1 = g.oracle.Insert<TestTypeInfo>().AppendData(new TestTypeInfo { Name = "Name" + DateTime.Now.ToString("yyyyMMddHHmmss") }).ExecuteIdentity();
|
||||
g.oracle.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)
|
||||
.ToList(a => a.Sum(a.Value.TypeGuid));
|
||||
|
||||
var aggsql1 = select
|
||||
.GroupBy(a => a.Title)
|
||||
.ToSql(b => new
|
||||
|
@ -86,6 +86,10 @@ namespace FreeSql.Tests.Odbc.Oracle
|
||||
sql = update.Set(a => a.Clicks == a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = trunc(\"CLICKS\" * 10 / 1) WHERE (\"ID\" = 1)", sql);
|
||||
|
||||
var dt2000 = DateTime.Parse("2000-01-01");
|
||||
sql = update.Set(a => a.Clicks == (a.CreateTime > dt2000 ? 1 : 2)).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = case when \"CREATETIME\" > to_timestamp('2000-01-01 00:00:00.000000','YYYY-MM-DD HH24:MI:SS.FF6') then 1 else 2 end WHERE (\"ID\" = 1)", sql);
|
||||
|
||||
sql = update.Set(a => a.Id == 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"ID\" = 10 WHERE (\"ID\" = 1)", sql);
|
||||
}
|
||||
|
@ -136,6 +136,19 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
}
|
||||
class TestDto2
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
|
||||
public TestDto2() { }
|
||||
public TestDto2(int id, string name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void ToList()
|
||||
{
|
||||
@ -150,6 +163,17 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
|
||||
var testDto33 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto { });
|
||||
var testDto44 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto() { });
|
||||
|
||||
var testDto211 = select.Limit(10).ToList(a => new TestDto2(a.Id, a.Title));
|
||||
var testDto212 = select.Limit(10).ToList(a => new TestDto2());
|
||||
var testDto213 = select.Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto214 = select.Limit(10).ToList(a => new 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 testDto2222 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2());
|
||||
var testDto2233 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto2244 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2() { });
|
||||
var testDto2255 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList<TestDto2>();
|
||||
|
||||
var t1 = g.pgsql.Select<TestInfo>().Where("").Where(a => a.Id > 0).Skip(100).Limit(200).ToSql();
|
||||
var t2 = g.pgsql.Select<TestInfo>().As("b").Where("").Where(a => a.Id > 0).Skip(100).Limit(200).ToSql();
|
||||
@ -724,6 +748,9 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
|
||||
var testpid1 = g.pgsql.Insert<TestTypeInfo>().AppendData(new TestTypeInfo { Name = "Name" + DateTime.Now.ToString("yyyyMMddHHmmss") }).ExecuteIdentity();
|
||||
g.pgsql.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)
|
||||
.ToList(a => a.Sum(a.Value.TypeGuid));
|
||||
|
||||
var aggsql1 = select
|
||||
.GroupBy(a => a.Title)
|
||||
.ToSql(b => new
|
||||
|
@ -87,6 +87,10 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
|
||||
sql = update.Set(a => a.Clicks == a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"tb_topic\" SET \"clicks\" = \"clicks\" * 10 / 1 WHERE (\"id\" = 1)", sql);
|
||||
|
||||
var dt2000 = DateTime.Parse("2000-01-01");
|
||||
sql = update.Set(a => a.Clicks == (a.CreateTime > dt2000 ? 1 : 2)).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"tb_topic\" SET \"clicks\" = case when \"createtime\" > '2000-01-01 00:00:00.000000' then 1 else 2 end WHERE (\"id\" = 1)", sql);
|
||||
|
||||
sql = update.Set(a => a.Id == 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"tb_topic\" SET \"id\" = 10 WHERE (\"id\" = 1)", sql);
|
||||
}
|
||||
|
@ -137,6 +137,19 @@ namespace FreeSql.Tests.Odbc.SqlServer
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
}
|
||||
class TestDto2
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; } //这是join表的属性
|
||||
public int ParentId { get; set; } //这是join表的属性
|
||||
|
||||
public TestDto2() { }
|
||||
public TestDto2(int id, string name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void ToList()
|
||||
{
|
||||
@ -150,6 +163,18 @@ namespace FreeSql.Tests.Odbc.SqlServer
|
||||
var testDto33 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto { });
|
||||
var testDto44 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto() { });
|
||||
|
||||
var testDto211 = select.Limit(10).ToList(a => new TestDto2(a.Id, a.Title));
|
||||
var testDto212 = select.Limit(10).ToList(a => new TestDto2());
|
||||
var testDto213 = select.Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto214 = select.Limit(10).ToList(a => new 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 testDto2222 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2());
|
||||
var testDto2233 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2 { });
|
||||
var testDto2244 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList(a => new TestDto2() { });
|
||||
var testDto2255 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).Limit(10).ToList<TestDto2>();
|
||||
|
||||
g.sqlserver.Insert<TestGuidIdToList>().AppendData(new TestGuidIdToList()).ExecuteAffrows();
|
||||
var testGuidId5 = g.sqlserver.Select<TestGuidIdToList>().ToList();
|
||||
var testGuidId6 = g.sqlserver.Select<TestGuidIdToList>().ToList(a => a.id);
|
||||
@ -618,6 +643,9 @@ namespace FreeSql.Tests.Odbc.SqlServer
|
||||
var testpid1 = g.sqlserver.Insert<TestTypeInfo>().AppendData(new TestTypeInfo { Name = "Name" + DateTime.Now.ToString("yyyyMMddHHmmss") }).ExecuteIdentity();
|
||||
g.sqlserver.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)
|
||||
.ToList(a => a.Sum(a.Value.TypeGuid));
|
||||
|
||||
var aggsql1 = select
|
||||
.GroupBy(a => a.Title)
|
||||
.ToSql(b => new
|
||||
|
@ -89,6 +89,10 @@ namespace FreeSql.Tests.Odbc.SqlServer
|
||||
sql = update.Set(a => a.Clicks == a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Clicks] = [Clicks] * 10 / 1 WHERE ([Id] = 1)", sql);
|
||||
|
||||
var dt2000 = DateTime.Parse("2000-01-01");
|
||||
sql = update.Set(a => a.Clicks == (a.CreateTime > dt2000 ? 1 : 2)).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Clicks] = case when [CreateTime] > '2000-01-01 00:00:00.000' then 1 else 2 end WHERE ([Id] = 1)", sql);
|
||||
|
||||
sql = update.Set(a => a.Id == 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Id] = 10 WHERE ([Id] = 1)", sql);
|
||||
}
|
||||
|
Reference in New Issue
Block a user