随笔分类 -  EF Core

摘要:1、Npgsql对 .NET 类型(如 List、Dictionary<string,object> 等)与 PostgreSQL 的 json/jsonb 字段的自动映射和序列化/反序列化,解决linq 转化成sql 解法:NpgsqlConnection.GlobalTypeMapper.Ena 阅读全文
posted @ 2025-06-25 09:01 Cody& 阅读(99) 评论(0) 推荐(0)
摘要:在DBContext类下,重写SaveChangesAsync方法,并插入修改实体逻辑,参考代码如下: public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cance 阅读全文
posted @ 2025-06-10 14:13 Cody& 阅读(26) 评论(0) 推荐(0)
摘要:1、新建interface public interface ISoftDelete { public bool isdeleted { get; set; } } 2、需要使用到软删除的entity要继承这个interface 3、然后在DBContext的OnModelCreating中为每个继 阅读全文
posted @ 2022-07-09 16:26 Cody& 阅读(492) 评论(0) 推荐(0)
摘要:在做单元测试的时候碰到以下报错: The instance of entity type 'XXX' cannot be tracked because another instance with the same key value for {'XX'} is already being trac 阅读全文
posted @ 2020-12-23 16:32 Cody& 阅读(4829) 评论(0) 推荐(1)
该文被密码保护。
posted @ 2020-06-12 22:23 Cody& 阅读(8) 评论(0) 推荐(0)