mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 修复 IUpdate.Set(a => a.xx = null) 表达式解析 bug;#311
This commit is contained in:
parent
2a3febdad5
commit
0991464fd0
@ -125,6 +125,13 @@
|
||||
清空状态数据
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
|
||||
<summary>
|
||||
根据 lambda 条件删除数据
|
||||
</summary>
|
||||
<param name="predicate"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||
<summary>
|
||||
添加
|
||||
@ -479,5 +486,14 @@
|
||||
<param name="that"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
||||
<summary>
|
||||
批量注入 Repository,可以参考代码自行调整
|
||||
</summary>
|
||||
<param name="services"></param>
|
||||
<param name="globalDataFilter"></param>
|
||||
<param name="assemblies"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using FreeSql.Internal;
|
||||
|
||||
namespace FreeSql.Tests.PerformanceTest
|
||||
{
|
||||
@ -24,7 +25,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
List<xxx> dplist1 = null;
|
||||
using (var conn = g.mysql.Ado.MasterPool.Get())
|
||||
{
|
||||
dplist1 = Dapper.SqlMapper.Query<xxx>(conn.Value, "select * from song").ToList();
|
||||
dplist1 = Dapper.SqlMapper.Query<xxx>(conn.Value, "select * from freesql_song").ToList();
|
||||
}
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Entity Counts: {dplist1.Count}; ORM: Dapper");
|
||||
@ -33,7 +34,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
List<(int, string, string)> dplist2 = null;
|
||||
using (var conn = g.mysql.Ado.MasterPool.Get())
|
||||
{
|
||||
dplist2 = Dapper.SqlMapper.Query<(int, string, string)>(conn.Value, "select * from song").ToList();
|
||||
dplist2 = Dapper.SqlMapper.Query<(int, string, string)>(conn.Value, "select * from freesql_song").ToList();
|
||||
}
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Tuple Counts: {dplist2.Count}; ORM: Dapper");
|
||||
@ -42,7 +43,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
List<dynamic> dplist3 = null;
|
||||
using (var conn = g.mysql.Ado.MasterPool.Get())
|
||||
{
|
||||
dplist3 = Dapper.SqlMapper.Query<dynamic>(conn.Value, "select * from song").ToList();
|
||||
dplist3 = Dapper.SqlMapper.Query<dynamic>(conn.Value, "select * from freesql_song").ToList();
|
||||
}
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Dynamic Counts: {dplist3.Count}; ORM: Dapper");
|
||||
@ -50,15 +51,15 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
|
||||
|
||||
|
||||
var t31 = g.mysql.Ado.Query<xxx>("select * from song limit 1");
|
||||
var t31 = g.mysql.Ado.Query<xxx>("select * from freesql_song limit 1");
|
||||
|
||||
time.Restart();
|
||||
var t3 = g.mysql.Ado.Query<xxx>("select * from song");
|
||||
var t3 = g.mysql.Ado.Query<xxx>("select * from freesql_song");
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Entity Counts: {t3.Count}; ORM: FreeSql*");
|
||||
|
||||
time.Restart();
|
||||
var t4 = g.mysql.Ado.Query<(int, string, string)>("select * from song");
|
||||
var t4 = g.mysql.Ado.Query<(int, string, string)>("select * from freesql_song");
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Tuple Counts: {t4.Count}; ORM: FreeSql*");
|
||||
|
||||
@ -68,7 +69,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query ToList<Tuple> Counts: {t41.Count}; ORM: FreeSql*");
|
||||
|
||||
time.Restart();
|
||||
var t5 = g.mysql.Ado.Query<dynamic>("select * from song");
|
||||
var t5 = g.mysql.Ado.Query<dynamic>("select * from freesql_song");
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Dynamic Counts: {t3.Count}; ORM: FreeSql*");
|
||||
|
||||
@ -86,7 +87,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
{
|
||||
using (var conn = g.mysql.Ado.MasterPool.Get())
|
||||
{
|
||||
dplist1.AddRange(Dapper.SqlMapper.Query<xxx>(conn.Value, "select * from song limit 10").ToList());
|
||||
dplist1.AddRange(Dapper.SqlMapper.Query<xxx>(conn.Value, "select * from freesql_song limit 10").ToList());
|
||||
}
|
||||
}
|
||||
time.Stop();
|
||||
@ -98,7 +99,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
{
|
||||
using (var conn = g.mysql.Ado.MasterPool.Get())
|
||||
{
|
||||
dplist2.AddRange(Dapper.SqlMapper.Query<(int, string, string)>(conn.Value, "select * from song limit 10").ToList());
|
||||
dplist2.AddRange(Dapper.SqlMapper.Query<(int, string, string)>(conn.Value, "select * from freesql_song limit 10").ToList());
|
||||
}
|
||||
}
|
||||
time.Stop();
|
||||
@ -110,7 +111,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
{
|
||||
using (var conn = g.mysql.Ado.MasterPool.Get())
|
||||
{
|
||||
dplist3.AddRange(Dapper.SqlMapper.Query<dynamic>(conn.Value, "select * from song limit 10").ToList());
|
||||
dplist3.AddRange(Dapper.SqlMapper.Query<dynamic>(conn.Value, "select * from freesql_song limit 10").ToList());
|
||||
}
|
||||
}
|
||||
time.Stop();
|
||||
@ -123,7 +124,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
List<xxx> t3 = new List<xxx>();
|
||||
for (var a = 0; a < 10000; a++)
|
||||
{
|
||||
t3.AddRange(g.mysql.Ado.Query<xxx>("select * from song limit 10"));
|
||||
t3.AddRange(g.mysql.Ado.Query<xxx>("select * from freesql_song limit 10"));
|
||||
}
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Entity Counts: {t3.Count}; ORM: FreeSql*");
|
||||
@ -132,7 +133,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
List<(int, string, string)> t4 = new List<(int, string, string)>();
|
||||
for (var a = 0; a < 10000; a++)
|
||||
{
|
||||
t4.AddRange(g.mysql.Ado.Query<(int, string, string)>("select * from song limit 10"));
|
||||
t4.AddRange(g.mysql.Ado.Query<(int, string, string)>("select * from freesql_song limit 10"));
|
||||
}
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Tuple Counts: {t4.Count}; ORM: FreeSql*");
|
||||
@ -141,7 +142,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
List<dynamic> t5 = new List<dynamic>();
|
||||
for (var a = 0; a < 10000; a++)
|
||||
{
|
||||
t5.AddRange(g.mysql.Ado.Query<dynamic>("select * from song limit 10"));
|
||||
t5.AddRange(g.mysql.Ado.Query<dynamic>("select * from freesql_song limit 10"));
|
||||
}
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Dynamic Counts: {t3.Count}; ORM: FreeSql*");
|
||||
@ -155,17 +156,53 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
var time = new Stopwatch();
|
||||
|
||||
//var t31 = g.mysql.Select<xxx>().ToList();
|
||||
g.mysql.Select<xxx>().First();
|
||||
|
||||
time.Restart();
|
||||
var t3 = g.mysql.Select<xxx>().ToList();
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; ToList Entity Counts: {t3.Count}; ORM: FreeSql*");
|
||||
|
||||
time.Restart();
|
||||
var adoarr1 = g.mysql.Ado.ExecuteArray("select * from freesql_song");
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; ExecuteArray Entity Counts: {adoarr1.Length}; ORM: FreeSql ExecuteArray*");
|
||||
|
||||
time.Restart();
|
||||
var adolist1 = new List<xxx>();
|
||||
g.mysql.Ado.ExecuteReader(dr =>
|
||||
{
|
||||
var xim = new xxx();
|
||||
var val1 = dr.GetValue(0);
|
||||
if (val1 is int) ;
|
||||
val1 = int.Parse(string.Format("{0}", val1));
|
||||
xim.Id = (int)val1;
|
||||
val1 = dr.GetValue(1);
|
||||
if (val1 is DateTime) ;
|
||||
val1 = (DateTime)val1;
|
||||
xim.Create_time = (DateTime)val1;
|
||||
val1 = dr.GetValue(2);
|
||||
if (val1 is int) ;
|
||||
val1 = int.Parse(string.Format("{0}", val1)) != 0;
|
||||
xim.Is_deleted = (bool)val1;
|
||||
val1 = dr.GetValue(3);
|
||||
if (val1 is string) ;
|
||||
val1 = (string)val1;
|
||||
xim.Title = (string)val1;
|
||||
val1 = dr.GetValue(4);
|
||||
if (val1 is string) ;
|
||||
val1 = (string)val1;
|
||||
xim.Title = (string)val1;
|
||||
adolist1.Add(xim);
|
||||
}, "select * from freesql_song");
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; ExecuteReader Entity Counts: {adolist1.Count}; ORM: FreeSql ExecuteReader*");
|
||||
|
||||
time.Restart();
|
||||
List<xxx> dplist1 = null;
|
||||
using (var conn = g.mysql.Ado.MasterPool.Get())
|
||||
{
|
||||
dplist1 = Dapper.SqlMapper.Query<xxx>(conn.Value, "select * from song").ToList();
|
||||
dplist1 = Dapper.SqlMapper.Query<xxx>(conn.Value, "select * from freesql_song").ToList();
|
||||
}
|
||||
time.Stop();
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Entity Counts: {dplist1.Count}; ORM: Dapper");
|
||||
@ -201,7 +238,7 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
{
|
||||
using (var conn = g.mysql.Ado.MasterPool.Get())
|
||||
{
|
||||
dplist1.AddRange(Dapper.SqlMapper.Query<xxx>(conn.Value, "select * from song limit 50").ToList());
|
||||
dplist1.AddRange(Dapper.SqlMapper.Query<xxx>(conn.Value, "select * from freesql_song limit 50").ToList());
|
||||
}
|
||||
}
|
||||
Interlocked.Add(ref dplist1Count, dplist1.Count);
|
||||
@ -211,12 +248,12 @@ namespace FreeSql.Tests.PerformanceTest
|
||||
sb.AppendLine($"Elapsed: {time.Elapsed}; Query Entity Counts: {dplist1Count}; ORM: Dapper");
|
||||
}
|
||||
|
||||
[Table(Name = "song")]
|
||||
[Table(Name = "freesql_song")]
|
||||
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; }
|
||||
}
|
||||
|
@ -148,6 +148,9 @@ namespace FreeSql.Tests.MySqlConnector
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE `tb_topic` SET `Clicks` = NULL WHERE (`Id` = 1)", sql);
|
||||
|
||||
var id = g.mysql.Insert<TestEnumUpdateTb>().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ExecuteIdentity();
|
||||
Assert.True(id > 0);
|
||||
sql = g.mysql.Update<TestEnumUpdateTb>().Where(a => a.id == id).Set(a => a.type, TestEnumUpdateTbType.biggit).ToSql().Replace("\r\n", "");
|
||||
|
@ -115,6 +115,9 @@ namespace FreeSql.Tests.Odbc.Dameng
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = NULL WHERE (\"ID\" = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -107,6 +107,9 @@ namespace FreeSql.Tests.Odbc.Default
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Clicks] = NULL WHERE ([Id] = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -148,6 +148,9 @@ namespace FreeSql.Tests.Odbc.MySql
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE `tb_topic` SET `Clicks` = NULL WHERE (`Id` = 1)", sql);
|
||||
|
||||
var id = g.mysql.Insert<TestEnumUpdateTb>().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ExecuteIdentity();
|
||||
Assert.True(id > 0);
|
||||
sql = g.mysql.Update<TestEnumUpdateTb>().Where(a => a.id == id).Set(a => a.type, TestEnumUpdateTbType.biggit).ToSql().Replace("\r\n", "");
|
||||
|
@ -105,6 +105,9 @@ namespace FreeSql.Tests.Odbc.Oracle
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = NULL WHERE (\"ID\" = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -106,6 +106,9 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"tb_topic\" SET \"clicks\" = NULL WHERE (\"id\" = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -108,6 +108,9 @@ namespace FreeSql.Tests.Odbc.SqlServer
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Clicks] = NULL WHERE ([Id] = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -115,6 +115,9 @@ namespace FreeSql.Tests.Dameng
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = NULL WHERE (\"ID\" = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -117,6 +117,9 @@ namespace FreeSql.Tests.MsAccess
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Clicks] = NULL WHERE ([Id] = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -149,6 +149,9 @@ namespace FreeSql.Tests.MySql
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE `tb_topic` SET `Clicks` = NULL WHERE (`Id` = 1)", sql);
|
||||
|
||||
var id = g.mysql.Insert<TestEnumUpdateTb>().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ExecuteIdentity();
|
||||
Assert.True(id > 0);
|
||||
sql = g.mysql.Update<TestEnumUpdateTb>().Where(a => a.id == id).Set(a => a.type, TestEnumUpdateTbType.biggit).ToSql().Replace("\r\n", "");
|
||||
|
@ -105,6 +105,9 @@ namespace FreeSql.Tests.Oracle
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = NULL WHERE (\"ID\" = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -107,6 +107,9 @@ namespace FreeSql.Tests.PostgreSQL
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"tb_topic\" SET \"clicks\" = NULL WHERE (\"id\" = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -118,6 +118,9 @@ namespace FreeSql.Tests.SqlServer
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE [tb_topic] SET [Clicks] = NULL WHERE ([Id] = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -124,6 +124,9 @@ namespace FreeSql.Tests.Sqlite
|
||||
|
||||
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);
|
||||
|
||||
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("UPDATE \"tb_topic\" SET \"Clicks\" = NULL WHERE (\"Id\" = 1)", sql);
|
||||
}
|
||||
[Fact]
|
||||
public void SetRaw()
|
||||
|
@ -1063,10 +1063,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
var firstTb = _tables[0];
|
||||
var firstTbs = _tables.Where(a => a.AliasInit == field[0]).ToArray();
|
||||
if (firstTbs.Length == 1)
|
||||
{
|
||||
firstTb = firstTbs[0];
|
||||
}
|
||||
if (firstTbs.Length == 1) firstTb = firstTbs[0];
|
||||
|
||||
firstTb.Parameter = Expression.Parameter(firstTb.Table.Type, firstTb.Alias);
|
||||
var currentType = firstTb.Table.Type;
|
||||
|
@ -409,7 +409,9 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
case ExpressionType.Equal:
|
||||
var equalBinaryExp = body as BinaryExpression;
|
||||
_set.Append(", ").Append(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, body, null, null));
|
||||
var eqval = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, body, null, null);
|
||||
if (eqval.EndsWith(" IS NULL")) eqval = $"{eqval.Remove(eqval.Length - 10)} = NULL"; //issues/311
|
||||
_set.Append(", ").Append(eqval);
|
||||
return this;
|
||||
case ExpressionType.MemberInit:
|
||||
var initExp = body as MemberInitExpression;
|
||||
|
@ -1363,10 +1363,10 @@ namespace FreeSql.Internal
|
||||
Expression.Block(
|
||||
Expression.IfThen(
|
||||
Expression.LessThan(dataIndexExp, rowLenExp),
|
||||
Expression.Return(returnTarget, Expression.New(RowInfo.Constructor,
|
||||
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { typeExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
||||
Expression.Add(dataIndexExp, Expression.Constant(1))))
|
||||
Expression.Return(returnTarget, Expression.New(RowInfo.Constructor,
|
||||
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { typeExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
||||
Expression.Add(dataIndexExp, Expression.Constant(1))))
|
||||
),
|
||||
Expression.Label(returnTarget, Expression.Default(typeof(RowInfo)))
|
||||
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
||||
@ -1442,7 +1442,7 @@ namespace FreeSql.Internal
|
||||
Expression.IfThen(
|
||||
Expression.AndAlso(
|
||||
Expression.IsFalse(readpknullExp),
|
||||
Expression.Or(
|
||||
Expression.OrElse(
|
||||
Expression.Equal(readpkvalExp, Expression.Constant(DBNull.Value)),
|
||||
Expression.Equal(readpkvalExp, Expression.Constant(null))
|
||||
)
|
||||
@ -1550,7 +1550,7 @@ namespace FreeSql.Internal
|
||||
Expression.IfThen(
|
||||
Expression.AndAlso(
|
||||
Expression.IsFalse(readpknullExp),
|
||||
Expression.Or(
|
||||
Expression.OrElse(
|
||||
Expression.Equal(readpkvalExp, Expression.Constant(DBNull.Value)),
|
||||
Expression.Equal(readpkvalExp, Expression.Constant(null))
|
||||
)
|
||||
@ -1718,7 +1718,7 @@ namespace FreeSql.Internal
|
||||
Expression.TypeEqual(valueExp, typeof(string)),
|
||||
Expression.Return(returnTarget, Expression.Call(Expression.Constant(DefaultEncoding), MethodEncodingGetBytes, Expression.Convert(valueExp, typeof(string)))),
|
||||
Expression.IfThenElse(
|
||||
Expression.Or(Expression.TypeEqual(valueExp, typeof(Guid)), Expression.TypeEqual(valueExp, typeof(Guid?))),
|
||||
Expression.OrElse(Expression.TypeEqual(valueExp, typeof(Guid)), Expression.TypeEqual(valueExp, typeof(Guid?))),
|
||||
Expression.Return(returnTarget, Expression.Call(MethodGuidToBytes, Expression.Convert(valueExp, typeof(Guid)))),
|
||||
Expression.Return(returnTarget, Expression.Call(Expression.Constant(DefaultEncoding), MethodEncodingGetBytes, Expression.Call(MethodToString, valueExp)))
|
||||
)
|
||||
@ -1969,11 +1969,11 @@ namespace FreeSql.Internal
|
||||
break;
|
||||
case "System.Boolean":
|
||||
tryparseBooleanExp = Expression.Return(returnTarget,
|
||||
Expression.Convert(
|
||||
Expression.Not(
|
||||
Expression.Or(
|
||||
Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("False")),
|
||||
Expression.Or(
|
||||
Expression.Convert(
|
||||
Expression.Not(
|
||||
Expression.OrElse(
|
||||
Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("False")),
|
||||
Expression.OrElse(
|
||||
Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("false")),
|
||||
Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("0"))))),
|
||||
typeof(object))
|
||||
@ -2027,7 +2027,7 @@ namespace FreeSql.Internal
|
||||
Expression.IfThenElse(
|
||||
Expression.TypeEqual(valueExp, typeof(byte[])),
|
||||
Expression.IfThenElse(
|
||||
Expression.Or(Expression.Equal(Expression.Constant(type), Expression.Constant(typeof(Guid))), Expression.Equal(Expression.Constant(type), Expression.Constant(typeof(Guid?)))),
|
||||
Expression.OrElse(Expression.Equal(Expression.Constant(type), Expression.Constant(typeof(Guid))), Expression.Equal(Expression.Constant(type), Expression.Constant(typeof(Guid?)))),
|
||||
Expression.Return(returnTarget, Expression.Convert(Expression.Call(MethodBytesToGuid, Expression.Convert(valueExp, typeof(byte[]))), typeof(object))),
|
||||
Expression.IfThenElse(
|
||||
Expression.Equal(Expression.Constant(type), Expression.Constant(typeof(string))),
|
||||
@ -2047,7 +2047,7 @@ namespace FreeSql.Internal
|
||||
new[] { valueExp },
|
||||
Expression.Assign(valueExp, Expression.Convert(value, typeof(object))),
|
||||
Expression.IfThenElse(
|
||||
Expression.Or(
|
||||
Expression.OrElse(
|
||||
Expression.Equal(valueExp, Expression.Constant(null)),
|
||||
Expression.Equal(valueExp, Expression.Constant(DBNull.Value))
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user