mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 优化 DbSet/Repository Attach 与 CanUpdate AuditValue 状态不同步问题;#1746
This commit is contained in:
parent
1f7e978699
commit
e1f91ef361
@ -9,6 +9,7 @@ using FreeSql.Internal.Model;
|
|||||||
using FreeSql.Odbc.Default;
|
using FreeSql.Odbc.Default;
|
||||||
using MessagePack;
|
using MessagePack;
|
||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
|
using MySqlConnector;
|
||||||
using NetTopologySuite.Geometries;
|
using NetTopologySuite.Geometries;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@ -571,7 +572,7 @@ namespace base_entity
|
|||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")
|
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
|
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
|
||||||
//.UseAdoConnectionPool(false)
|
//.UseAdoConnectionPool(false)
|
||||||
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
|
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
|
||||||
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
|
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
|
||||||
@ -611,6 +612,18 @@ namespace base_entity
|
|||||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
fsql.Aop.AuditValue += (_, e) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var tt1 = new ProjectItem { ID = 1, MaxQuantity = 0, Code = null, Name = null };
|
||||||
|
var tt2 = new ProjectItem { ID = 1, MaxQuantity = 100, Code = null, Name = null };
|
||||||
|
var repot2 = fsql.GetRepository<ProjectItem>();
|
||||||
|
|
||||||
|
repot2.Attach(tt1);
|
||||||
|
var nt1 = repot2.Update(tt2);
|
||||||
|
|
||||||
var fsql2 = fsql;
|
var fsql2 = fsql;
|
||||||
// 动态构建实体类型,树形结构,引用自身类型
|
// 动态构建实体类型,树形结构,引用自身类型
|
||||||
var areaBuilder = fsql2.CodeFirst.DynamicEntity("Area", new TableAttribute { Name = "dy_area" });
|
var areaBuilder = fsql2.CodeFirst.DynamicEntity("Area", new TableAttribute { Name = "dy_area" });
|
||||||
@ -3192,4 +3205,34 @@ public class VM_District_Parent : BaseDistrict
|
|||||||
|
|
||||||
[Navigate(nameof(ParentCode))]
|
[Navigate(nameof(ParentCode))]
|
||||||
public VM_District_Parent Parent { get; set; }
|
public VM_District_Parent Parent { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonObject(MemberSerialization.OptIn), Table(DisableSyncStructure = true)]
|
||||||
|
public partial class ProjectItem
|
||||||
|
{
|
||||||
|
[JsonProperty, Column(DbType = "bigint", IsPrimary = true, IsIdentity = true)]
|
||||||
|
public long ID { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编码
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty, Column(StringLength = 100, IsNullable = false)]
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 实际最大用量
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty, Column(DbType = "decimal(14,4)")]
|
||||||
|
public decimal MaxQuantity { get; set; } = 0.0000M;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty, Column(StringLength = 50, IsNullable = false)]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -316,6 +316,21 @@
|
|||||||
这个不行
|
这个不行
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:ProjectItem.Code">
|
||||||
|
<summary>
|
||||||
|
编码
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:ProjectItem.MaxQuantity">
|
||||||
|
<summary>
|
||||||
|
实际最大用量
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:ProjectItem.Name">
|
||||||
|
<summary>
|
||||||
|
名称
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:EMSServerModel.Model.Role">
|
<member name="T:EMSServerModel.Model.Role">
|
||||||
<summary>
|
<summary>
|
||||||
角色表
|
角色表
|
||||||
|
@ -239,6 +239,7 @@ namespace FreeSql
|
|||||||
if (_table.Primarys.Any() == false) throw new Exception(DbContextStrings.CannotAttach_EntityHasNo_PrimaryKey(_db.OrmOriginal.GetEntityString(_entityType, data.First())));
|
if (_table.Primarys.Any() == false) throw new Exception(DbContextStrings.CannotAttach_EntityHasNo_PrimaryKey(_db.OrmOriginal.GetEntityString(_entityType, data.First())));
|
||||||
foreach (var item in data)
|
foreach (var item in data)
|
||||||
{
|
{
|
||||||
|
FreeSql.Internal.CommonProvider.UpdateProvider<TEntity>.AuditDataValue(this, item, _db.OrmOriginal, _table, null); //与 CanUpdate 同步
|
||||||
var key = _db.OrmOriginal.GetEntityKeyString(_entityType, item, false);
|
var key = _db.OrmOriginal.GetEntityKeyString(_entityType, item, false);
|
||||||
if (string.IsNullOrEmpty(key)) throw new Exception(DbContextStrings.CannotAttach_PrimaryKey_NotSet(_db.OrmOriginal.GetEntityString(_entityType, item)));
|
if (string.IsNullOrEmpty(key)) throw new Exception(DbContextStrings.CannotAttach_PrimaryKey_NotSet(_db.OrmOriginal.GetEntityString(_entityType, item)));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user