So we are building an application with a
所以我们正在构建一个带有的应用程序
- UI Layer (web, mobile, Ajax client, etc)
- UI层(Web,移动,Ajax客户端等)
- Service/API Layer
- 服务/ API层
- Business Logic Layer
- 业务逻辑层
- Data Access Layer
- 数据访问层
Our goal is to have an Entity Framework dependency from the Service Layer on down to the DAL. That means the Sevice layer will only accept and return POCOs (plain old CLR objects).
我们的目标是从服务层到DAL具有实体框架依赖关系。这意味着Sevice层只接受并返回POCO(普通的旧CLR对象)。
What we're currently doing is manually coding a mapping layer between the service layer and business logic layer that will convert POCOs to EF Entities and vice versa.
我们目前正在做的是手动编码服务层和业务逻辑层之间的映射层,将POCO转换为EF实体,反之亦然。
So in short, page has form, form has codebehind that takes form contents, stuffs them into a POCO, sends it to service layer. Service layer converts to EF Entity, sends it to Business Logic Layer which performs certain transformations to the entity, and then interacts with the DAL to get it persisted.
所以总之,页面有表格,表格有代码隐藏,表格内容,把它们塞进POCO,发送到服务层。服务层转换为EF实体,将其发送到业务逻辑层,业务逻辑层对实体执行某些转换,然后与DAL交互以使其持久化。
Yes, its a bit tedious, but we were wondering if theres a better way?
是的,它有点乏味,但我们想知道是否有更好的方法?
Yes, I know someone published an EF Poco Adapter but it's all in C# and we would prefer a VB.NET solution.
是的,我知道有人发布了EF Poco适配器,但它全部都在C#中,我们更喜欢VB.NET解决方案。
Yes, Switching to NHibernate is an option of last resort, as we are already deep into our development cycle.
是的,切换到NHibernate是最后的选择,因为我们已经深入到我们的开发周期。
2 个解决方案
#1
2
You should be performing business logic on POCOs. The entire purpose of ORM is that it is an implementation detail. The business logic should be implemented in the domain model and in the domain services - in a business application, "domain" means "business". The DAL should be there to take a POCO and persist it - in your case, that means mapping it to and persisting an EF entity.
您应该在POCO上执行业务逻辑。 ORM的全部目的是它是一个实现细节。业务逻辑应该在域模型和域服务中实现 - 在业务应用程序中,“域”意味着“业务”。 DAL应该在那里采取POCO并坚持它 - 在您的情况下,这意味着将其映射到并持久化EF实体。
That's the theoretical / NHibernate model, at any rate.
无论如何,这是理论/ NHibernate模型。
#2
1
Can you stand having a dependency in the service layer on the EF interfaces? You could implement IPOCO.
你能否在EF接口的服务层中拥有依赖关系?您可以实施IPOCO。
There's even a way to do it automatically.
甚至还有一种方法可以自动完成。
#1
2
You should be performing business logic on POCOs. The entire purpose of ORM is that it is an implementation detail. The business logic should be implemented in the domain model and in the domain services - in a business application, "domain" means "business". The DAL should be there to take a POCO and persist it - in your case, that means mapping it to and persisting an EF entity.
您应该在POCO上执行业务逻辑。 ORM的全部目的是它是一个实现细节。业务逻辑应该在域模型和域服务中实现 - 在业务应用程序中,“域”意味着“业务”。 DAL应该在那里采取POCO并坚持它 - 在您的情况下,这意味着将其映射到并持久化EF实体。
That's the theoretical / NHibernate model, at any rate.
无论如何,这是理论/ NHibernate模型。
#2
1
Can you stand having a dependency in the service layer on the EF interfaces? You could implement IPOCO.
你能否在EF接口的服务层中拥有依赖关系?您可以实施IPOCO。
There's even a way to do it automatically.
甚至还有一种方法可以自动完成。