ASP.NET Web API适合哪些地方? [英] Where does ASP.NET Web API fit ?

查看:69
本文介绍了ASP.NET Web API适合哪些地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上周末,我参加了ASP.NET Web API课程,但我很难理解它在使用方面的适用范围。做了一些谷歌研究,但仍然困惑。



1.我可以看到在数据库上实现CURD操作是好的,但是我应该在web api中实现业务逻辑吗?



2.说我有一个工作单位。检查客户是否存在于数据库中,如果是,则获取最后10个订单。这应该采用web-api中的单一方法还是两种方法来检查客户和其他方法以获取订单?到目前为止,我已经看到在单个数据库资源上实现CURD的示例。



3.如果我不得不想象使用web-api的应用程序架构我认为



前端 - 在MVC中

业务逻辑 - 从控制器调用的独立业务逻辑类库,它又调用Web API?

数据库逻辑 - 使用Web -API实现CURD?

Over the weekend I have taken a course on ASP.NET Web API but I am struggling to understand where does it fit in terms of usage. Did some google research but still confused.

1. I can see it is good for implementing CURD operations on database but should I implement business logic in web api ?

2. Say I have a unit of work. Check customer exists in database and if so get the last 10 orders. Should this go in a single method in web-api or two methods one to check for customer and other to get orders ? So far I have seen examples implementing CURD on a single database resource.

3.If I have to imagine an application architecture using web-api i think

front end - in MVC
business logic - Separate Business Logic class library called from Controllers and it in turn call Web API ?
database logic - Use Web -API to implement CURD ?

推荐答案

在普通的ASP.Net中你仍然会遵循MVC原则。使类表示数据表,中间类来管理和查询数据以及网页来查看它们。



ASP.Net MVC做了很多艰苦的工作对于你 - 引擎盖下。

我建议你做一个例子,并参观w3schools和MVC教程。
In plain ASP.Net you would still follow MVC principles. Make classes to represent the data tables, middle classes to manage and query the data and the web pages to view them.

ASP.Net MVC does much of the hard work for you- under the hood.
I suggest you do one example of each and visit w3schools and MVC tutorials.


这篇关于ASP.NET Web API适合哪些地方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆