简体   繁体   English

在没有实体框架的情况下构建OData API

[英]Build OData API without Entity Framework

I have an existing web forms project which consists of 3 different projects: UI layer (Web project), Business Logic Layer and Database Project. 我有一个现有的Web窗体项目,该项目包含3个不同的项目:UI层(Web项目),业务逻辑层和数据库项目。 I have already written the data access methods which connect to the database and return data to the business logic layer. 我已经写了连接到数据库并将数据返回到业务逻辑层的数据访问方法。

Now we need to provide a REST API, and I was thinking of using oData API along with REST. 现在我们需要提供一个REST API,我当时正在考虑将oData API与REST一起使用。 But all the examples I have seen use Entity Framework and I just cannot use Entity Framework because our data access layer returns data to the business layer, which then processes that data and adds some logic, and then present it to the UI layer. 但是我看到的所有示例都使用Entity Framework,而我不能使用Entity Framework,因为我们的数据访问层将数据返回到业务层,然后业务层处理该数据并添加一些逻辑,然后将其呈现给UI层。

Can I still use oData API? 我仍然可以使用oData API吗? If yes, then will I need to create fresh methods manually for each of the complex query of oData API? 如果是,那么我是否需要为oData API的每个复杂查询手动创建新方法? How will OData API access my BL Layer? OData API如何访问我的BL层?

You can do this (I have just done similar myself) but it is very hard work. 您可以做到这一点(我自己也做过类似的事情),但这是非常艰巨的工作。

To me, OData always felt like a way of exposing the entity framework through web services so if you were to try and implement it without the entity framework you will end up spending a lot of time parsing queries to your data access layer. 对我而言,OData始终感觉像是一种通过Web服务公开实体框架的方法,因此,如果您尝试在没有实体框架的情况下实现它,则最终将花费大量时间将查询解析到数据访问层。

If you do decide to go down this route, maybe consider only implementing part of the OData spec - work out which parts you actually want to be able to use - as it is huge and the task is daunting. 如果您确实决定走这条路,也许考虑只实现OData规范的一部分-确定您真正想使用的哪些部分-因为它庞大且任务艰巨。

These are only from my experiences though and you may have a better data access layer API setup than I had when I started which could make things significantly easier. 不过,这些只是我的经验,与开始时相比,您可能具有更好的数据访问层API设置,这可以使事情变得更加容易。

EDIT to answer last question: 编辑以回答最后一个问题:

Will you need to create fresh methods manually for each of the complex query of oData API? 您是否需要为oData API的每个复杂查询手动创建新方法? This will really depend on how your data will be exposed and how your data access layer is setup. 这实际上取决于如何公开您的数据以及如何设置数据访问层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 构建响应实体而不发送它 - Build Response Entity without sending it 如何通过oData创建新的子节点实体而不更新或创建根节点 - How to create a new Child node entity via oData without updating or creating the root node 如何在 Olingo OData V4 java API 中创建枚举实体类型 - How to create an enum entity type in Olingo OData V4 java API 使用Spring框架构建库或API是否很好 - Is it good to build library or API using Spring framework Java REST API 框架,无 Maven/Gradle - Java REST API framework without Maven/Gradle 如何在没有框架的情况下使用 java 实体 class 管理关系(mysql)表 - how to manage relationship (mysql) tables with java entity class, without a framework 玩! 框架不接受没有@Entity注释的@MappedSuperclass - Play! framework don't accept my @MappedSuperclass without @Entity annotation Odata ClientEntity错误-预期的OData实体,找到了EntitySet - Odata ClientEntity Error - Expected OData Entity, found EntitySet 在Spring框架中基于实体对象调用不同的Service api - Call different Service api's based on the entity object in spring framework 是否可以在不使用框架的情况下构建Java Web应用程序? - Is it possible to build a Java web application without using a framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM