简体   繁体   English

OData是否适合大型MVC5 / WebAPI应用程序

[英]Is OData suitable for a big MVC5/WebAPI application

I was working with the following stack MVC5 + WebAPI 2.2 + EF6 + AngularJS for my web application. 我正在为我的Web应用程序使用以下堆栈MVC5 + WebAPI 2.2 + EF6 + AngularJS。 Today, I tried to incorporate OData and Angular BreezeJS into my application and it worked fine for one of the entities. 今天,我尝试将ODataAngular BreezeJS合并到我的应用程序中,并且对于其中一个实体来说效果很好。

Currently, I have around 45 tables which translate to 45 model classes. 目前,我有大约45个表格,可以转换为45个模型类。

In Web API, I could have just have 5-10 controllers to handle the CRUD operations for the 45 models using a switch statement based on the variables I pass like entityName , operationName . 在Web API中,我可能只有5-10个控制器,可以根据我传递的变量(例如entityNameoperationName使用switch语句来处理45个模型的CRUD operationName

But, in OData I need 45 controllers scaffold-ed by VS. 但是,在OData中,我需要由VS支撑的45个控制器。 Is there any way I can use the benefits of OData such as querying/paging/patching without having to create a controller for each model class ? 有什么方法可以利用OData的好处,例如querying/paging/patching而不必为每个模型类创建一个控制器?

Do you work with Entity Framework ? 您是否使用Entity Framework? If so, you can try with RESTier. 如果是这样,您可以尝试使用RESTier。 RESTier is built upon Web API OData , and it need only ONE controller to make all the basic CRUD (including queries) work. RESTier 基于Web API OData构建 ,并且只需要一个控制器即可使所有基本CRUD(包括查询)正常工作。

You can learn more from the tutorial http://odata.github.io/RESTier/Getting-Started-Part-1/ and a sample with Northwind locates at https://github.com/OData/RESTier/tree/master/src/Microsoft.Restier.Samples.Northwind . 您可以从教程http://odata.github.io/RESTier/Getting-Started-Part-1/中了解更多信息,有关Northwind的示例位于https://github.com/OData/RESTier/tree/master/ src / Microsoft.Restier.Samples.Northwind

I have done this for an admin system for an ecommerce company. 我已经为电子商务公司的管理系统完成了此任务。 Probably about 20 tables and related api controllers, some of the tables have 10,000's record and all controllers have the odata bits enabled. 大约有20个表和相关的api控制器,其中一些表具有10,000条记录,并且所有控制器都启用了odata位。 It seems fine for me so far on Azure SQL and websites. 到目前为止,对我而言,在Azure SQL和网站上似乎还不错。 I am using a controller per model/entity, why are you against doing that? 我在每个模型/实体上都使用控制器,为什么反对这样做?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM