Closed Zero-Xiong closed 9 months ago
未重现你的问题
下面是完整的测试用例,你可以新建库进行测试
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace OrmTest
{
internal class Unitdfafaaa
{
public static void Init()
{
var db = NewUnitTest.Db;
db.CodeFirst.InitTables<Invoice>();
var result = db.Updateable<Invoice>(new Invoice() { })
.WhereColumns(c => new { c.comp_code, c.adi_order, c.invoice_no, c.cust_po_no })
.UpdateColumns(u => new { u.customer_original_po })
.ExecuteCommandAsync().GetAwaiter().GetResult();
}
[SqlSugar.SugarTable("inv_master")]
public class Invoice
{
[SqlSugar.SugarColumn(IsIdentity = true)]
public long id { get; set; }
public string comp_code { get; set; } = "a";
public string adi_order { get; set; } = "a";
public string invoice_no { get; set; } = "a";
public string cust_po_no { get; set; } = "a";
public string customer_original_po { get; set; } = "a";
}
}
}
使用版本:
SqlSugarCore (Version="5.1.4.110" ) .NET 7
使用例子: result = await db.Updateable(records)
.WhereColumns(c => new { c.c1, c.c2, c.c3, c.c4 })
.UpdateColumns(u => new { u.column_to_be_updated })
.ExecuteCommandAsync();
错误信息:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'T' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at SqlSugar.SerializeService.DeserializeObject[T](String value) at SqlSugar.ContextMethods.DeserializeObject[T](String value) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at SqlSugar.SqlSugarProvider.Updateable[T](Object updateDynamicObject) at SqlSugar.SqlSugarScopeProvider.Updateable[T](Object updateDynamicObject)