具有“工作单元”的最佳项目模式在业务层
我有一个 C# .NET 桌面项目,其结构如下:gui、业务和数据访问层。每个业务层类代表数据库的一个实体。我正在使用 linq 来访问数据库。但目前项目的实现方式不允许以原子方式进行许多操作,我需要在业务层中完成此操作。
我搜索了一些设计模式,发现unitOfWork使数据层中的所有操作都在同一上下文中并且在提交所有更改之后。这将使操作原子化。但问题是我想要执行的操作需要之前进行验证,这意味着我需要先调用业务层的方法来进行验证,而不是从数据层调用方法。业务层中的此调用将创建另一个工作单元,从而创建另一个上下文,破坏我正在尝试执行的更大操作的原子性。
问题是:在同一 linq 上下文中从业务层调用业务层的一个或多个方法的最佳项目模式是什么?
I have a desktop project in C# .NET that is structured in: gui, business and data access layers. Each business layer class represent an entity of the database. I am using linq to access the database. But the the way the project is implemented today does not allow to make many operations atomically, and i need this to be done in business layer.
I searched to some design patterns and found unitOfWork that makes all operation in data layer in the same context and after all the changes are submitted. This would work to make the operations atomic. But the problem is that the operations I want to do need to be validated before, that means, instead of calling a method from data layer i need to call a method from business layer to be validated before. This call in the business layer would create another unitOfWork and, consequently, create another context breaking the atomicity of the bigger operation I am trying to do.
The question is: What the best project pattern to call one or more methods of the business layer from the business layer in the same linq context?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是:
One way of doing it would be: