mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 修复 DbContext/Repository Update 不更新 DbUpdateValue 的问题;#219
This commit is contained in:
parent
761b6e0068
commit
f22f65fee9
@ -110,13 +110,6 @@
|
|||||||
清空状态数据
|
清空状态数据
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</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)">
|
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||||
<summary>
|
<summary>
|
||||||
添加
|
添加
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.LazyLoading\FreeSql.Extensions.LazyLoading.csproj" />
|
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.LazyLoading\FreeSql.Extensions.LazyLoading.csproj" />
|
||||||
|
<ProjectReference Include="..\..\FreeSql.DbContext\FreeSql.DbContext.csproj" />
|
||||||
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
||||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.MySqlConnector\FreeSql.Provider.MySqlConnector.csproj" />
|
<ProjectReference Include="..\..\Providers\FreeSql.Provider.MySqlConnector\FreeSql.Provider.MySqlConnector.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -57,6 +57,30 @@ namespace FreeSql.Tests.MySqlConnector
|
|||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
g.mysql.Update<测试中文表2>().SetSource(item2).ExecuteAffrows();
|
g.mysql.Update<测试中文表2>().SetSource(item2).ExecuteAffrows();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.mysql.Update<测试中文表2>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.mysql.GetRepository<测试中文表2>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表2
|
class 测试中文表2
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,28 @@ namespace FreeSql.Tests.Odbc.Dameng
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.dameng.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.dameng.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.dameng.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.dameng.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.dameng.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,28 @@ namespace FreeSql.Tests.Odbc.Default
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.odbc.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.odbc.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.odbc.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.odbc.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.odbc.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -55,6 +55,28 @@ namespace FreeSql.Tests.Odbc.MySql
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.mysql.Update<测试中文表2>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.mysql.GetRepository<测试中文表2>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表2
|
class 测试中文表2
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,28 @@ namespace FreeSql.Tests.Odbc.Oracle
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.oracle.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.oracle.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,28 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.pgsql.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.pgsql.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,28 @@ namespace FreeSql.Tests.Odbc.SqlServer
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.sqlserver.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.sqlserver.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.sqlserver.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.sqlserver.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.sqlserver.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,28 @@ namespace FreeSql.Tests.MsAccess
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.msaccess.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.msaccess.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.msaccess.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.msaccess.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.msaccess.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,28 @@ namespace FreeSql.Tests.MySql
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题22 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.mysql.Update<测试中文表2>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题22, item2.标题22);
|
||||||
|
|
||||||
|
item.标题22 = "测试标题更新_repo";
|
||||||
|
var repo = g.mysql.GetRepository<测试中文表2>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题22, item2.标题22);
|
||||||
|
|
||||||
|
item.标题22 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.mysql.Select<测试中文表2>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题22, item2.标题22);
|
||||||
}
|
}
|
||||||
class 测试中文表2
|
class 测试中文表2
|
||||||
{
|
{
|
||||||
@ -60,6 +82,8 @@ namespace FreeSql.Tests.MySql
|
|||||||
|
|
||||||
public string 标题 { get; protected set; }
|
public string 标题 { get; protected set; }
|
||||||
|
|
||||||
|
public string 标题22 { get; set; }
|
||||||
|
|
||||||
[Column(ServerTime = DateTimeKind.Local, CanUpdate = false)]
|
[Column(ServerTime = DateTimeKind.Local, CanUpdate = false)]
|
||||||
public DateTime 创建时间 { get; protected set; }
|
public DateTime 创建时间 { get; protected set; }
|
||||||
|
|
||||||
@ -68,7 +92,7 @@ namespace FreeSql.Tests.MySql
|
|||||||
|
|
||||||
public static 测试中文表2 Create(string title, DateTime ctm)
|
public static 测试中文表2 Create(string title, DateTime ctm)
|
||||||
{
|
{
|
||||||
return new 测试中文表2 { 标题 = title, 创建时间 = ctm };
|
return new 测试中文表2 { 标题 = title, 标题22 = title, 创建时间 = ctm };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,28 @@ namespace FreeSql.Tests.Oracle
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.oracle.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.oracle.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,28 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.pgsql.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.pgsql.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,28 @@ namespace FreeSql.Tests.SqlServer
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.sqlserver.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.sqlserver.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.sqlserver.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.sqlserver.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.sqlserver.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,28 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.sqlite.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.sqlite.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.sqlite.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.sqlite.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.sqlite.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
|
@ -57,6 +57,14 @@ namespace FreeSql.Tests
|
|||||||
.Any())
|
.Any())
|
||||||
.ToSql(a => a.Name);
|
.ToSql(a => a.Name);
|
||||||
|
|
||||||
|
sql = context.Songs
|
||||||
|
.Where(a =>
|
||||||
|
context.Authors
|
||||||
|
.Select //加上这句就不报错,不加上报 variable 'a' of type 'Song' referenced from scope '', but it is not defined
|
||||||
|
.Where(b => b.SongId == a.Id)
|
||||||
|
.Any())
|
||||||
|
.ToSql(a => a.Name);
|
||||||
|
|
||||||
//using (var conn = new SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=webchat-abc;Pooling=true;Max Pool Size=13"))
|
//using (var conn = new SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=webchat-abc;Pooling=true;Max Pool Size=13"))
|
||||||
//{
|
//{
|
||||||
// conn.Open();
|
// conn.Open();
|
||||||
|
@ -553,20 +553,31 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
{
|
{
|
||||||
if (_table.ColumnsByCs.TryGetValue(prop.Name, out var trycol) == false) continue;
|
if (_table.ColumnsByCs.TryGetValue(prop.Name, out var trycol) == false) continue;
|
||||||
exps.Add(
|
exps.Add(
|
||||||
Expression.IfThenElse(
|
trycol.Attribute.CanUpdate == false ?
|
||||||
Expression.Equal(
|
|
||||||
Expression.MakeMemberAccess(var1Parm, prop),
|
|
||||||
Expression.MakeMemberAccess(var2Parm, prop)
|
|
||||||
),
|
|
||||||
Expression.IfThen(
|
Expression.IfThen(
|
||||||
Expression.IsTrue(parm3),
|
Expression.IsTrue(parm3),
|
||||||
Expression.Call(var1Ret, typeof(List<string>).GetMethod("Add", new Type[] { typeof(string) }), Expression.Constant(trycol.Attribute.Name))
|
Expression.Call(var1Ret, typeof(List<string>).GetMethod("Add", new Type[] { typeof(string) }), Expression.Constant(trycol.Attribute.Name))
|
||||||
),
|
) : (
|
||||||
Expression.IfThen(
|
trycol.Attribute.CanUpdate && string.IsNullOrEmpty(trycol.DbUpdateValue) == false ?
|
||||||
Expression.IsFalse(parm3),
|
Expression.IfThen(
|
||||||
Expression.Call(var1Ret, typeof(List<string>).GetMethod("Add", new Type[] { typeof(string) }), Expression.Constant(trycol.Attribute.Name))
|
Expression.IsFalse(parm3),
|
||||||
|
Expression.Call(var1Ret, typeof(List<string>).GetMethod("Add", new Type[] { typeof(string) }), Expression.Constant(trycol.Attribute.Name))
|
||||||
|
) :
|
||||||
|
Expression.IfThenElse(
|
||||||
|
Expression.Equal(
|
||||||
|
Expression.MakeMemberAccess(var1Parm, prop),
|
||||||
|
Expression.MakeMemberAccess(var2Parm, prop)
|
||||||
|
),
|
||||||
|
Expression.IfThen(
|
||||||
|
Expression.IsTrue(parm3),
|
||||||
|
Expression.Call(var1Ret, typeof(List<string>).GetMethod("Add", new Type[] { typeof(string) }), Expression.Constant(trycol.Attribute.Name))
|
||||||
|
),
|
||||||
|
Expression.IfThen(
|
||||||
|
Expression.IsFalse(parm3),
|
||||||
|
Expression.Call(var1Ret, typeof(List<string>).GetMethod("Add", new Type[] { typeof(string) }), Expression.Constant(trycol.Attribute.Name))
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user