程序设计之术
工作单元模式
01实体
02数据库上下文
03仓储
04工作单元
05服务
06调用
本文档使用 MrDoc 发布
-
+
首页
04工作单元
```java public interface IUnitOfWork : IDisposable { IProductRepository Products { get; } int Complete(); } ``` ```java public class UnitOfWork : IUnitOfWork { private readonly AppDbContext _context; public IProductRepository Products { get; private set; } public UnitOfWork(AppDbContext context, IProductRepository productRepository) { _context = context; Products = productRepository; } public int Complete() { return _context.SaveChanges(); } public void Dispose() { _context.Dispose(); } } ```
孙端己
2024年7月30日 10:56
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码