修复DObject转对象的错误,不能使用Adapt,改成使用json反序列化

This commit is contained in:
2023-09-25 11:45:45 +08:00
parent 821737473e
commit bc8401c8e9
2 changed files with 9 additions and 18 deletions

View File

@@ -83,7 +83,7 @@ public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
{ {
ThrowIf.IsNull(input.data); ThrowIf.IsNull(input.data);
//ArgumentNullException.ThrowIfNull(input.data); //ArgumentNullException.ThrowIfNull(input.data);
Vmodel vm = input.data.Adapt<Vmodel>(); Vmodel vm = input.data.ToObject<Vmodel>();
vm.areaCode = vm.areaCode.ToKebab(); vm.areaCode = vm.areaCode.ToKebab();
vm.vmCode = vm.vmCode.ToKebab(); vm.vmCode = vm.vmCode.ToKebab();
await _db.Insertable(vm).ExecuteCommandAsync(); await _db.Insertable(vm).ExecuteCommandAsync();
@@ -97,7 +97,7 @@ public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
{ {
ThrowIf.IsNull(input.data); ThrowIf.IsNull(input.data);
//ArgumentNullException.ThrowIfNull(input.data); //ArgumentNullException.ThrowIfNull(input.data);
Vmodel vm = input.data.Adapt<Vmodel>(); Vmodel vm = input.data.ToObject<Vmodel>();
vm.areaCode = vm.areaCode.ToKebab(); vm.areaCode = vm.areaCode.ToKebab();
vm.vmCode = vm.vmCode.ToKebab(); vm.vmCode = vm.vmCode.ToKebab();
vm.navProps.ForEach(a => a.naviModel = null); vm.navProps.ForEach(a => a.naviModel = null);

View File

@@ -20,37 +20,28 @@ public class VmNavProp : VmBaseProp
public string vmid { get; set; } = string.Empty; public string vmid { get; set; } = string.Empty;
/// <summary> /// <summary>
/// 导航关联类型 /// 导航关联类型, 1:一对一,2:一对多
/// </summary> /// </summary>
public eNavigateType navType { get; set; } public eNavigateType navType { get; set; }
/// <summary> /// <summary>
/// 源表字段 /// 源表代码,默认为m,表示与主表关联,可设置为中间表导航属性code,用来表示多对多
/// </summary> /// </summary>
public string refCode { get; set; } = VmSelectProp.MAIN_ALIES; public string refCode { get; set; } = VmSelectProp.MAIN_ALIES;
/// <summary> /// <summary>
/// 被引用字段 /// 源表字段, 源表的外键字段
/// </summary> /// </summary>
public string refField { get; set; } = string.Empty; public string refField { get; set; } = string.Empty;
/// <summary> /// <summary>
/// 表字段 /// 导航表字段
/// </summary> /// </summary>
public string fkField { get; set; } = string.Empty; public string fkField { get; set; } = string.Empty;
///// <summary> /// <summary>
///// 关联表表名 /// 关联模型
///// </summary> /// </summary>
//[JsonIgnore]
//public string refTable { get; set; } = string.Empty;
///// <summary>
///// 被引用表(中间表)
///// </summary>
//[JsonIgnore]
//public string? midTable { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public Vmodel? naviModel { get; set; } public Vmodel? naviModel { get; set; }