自定义枚举类型转换出错 返回

SqlSugar 沟通中
3 239
该叫什么 Coder 发布于2025/11/18
悬赏:0 飞吻
[SugarTable]
public class Test
{
    [SugarColumn(IsPrimaryKey =true)]
    public int Id { get; set; }
    [SugarColumn(IsPrimaryKey = true,SqlParameterDbType = typeof(EnumToStringConvert))]
    public MyType Type { get; set; }
    public string? Name { get; set; }
}

public enum MyType
{
    Type1, Type2
}

var test = new Test()
{
    Id = 1,
    Type = MyType.Type1,
    Name = "3"
};
client.Deleteable<Test>().ExecuteCommand();

client.Storageable(test).ExecuteCommand();

client.Storageable(test).ExecuteCommand();
Console.WriteLine("OK");

代码如上,在第二次调用Storageable的时候,此时应该执行的是update操作,这个时候报数据类型转换失败,如下图

image.png

热忱回答3