简体   繁体   English

带有.NET后端的Azure移动服务中的存储过程?

[英]Stored procedures in Azure Mobile Service with .NET backend?

So there's documentation on how to call stored procedures from an Azure Mobile Service with a Javascript backend found here . 因此,有关于如何调用从Azure的移动服务存储程序,发现一个JavaScript后端文档在这里 But I don't see any documentation for the .NET backend. 但是我看不到任何有关.NET后端的文档。 In that article it says that the .NET backend is has a completely different architecture. 在那篇文章中,它说.NET后端具有完全不同的体系结构。

My question is: How are stored procedures handled in the .NET backend? 我的问题是:.NET后端如何处理存储过程? Would I create ADO.NET connections to the database and expose a call to the stored procedure via a custom API method? 我将创建到数据库的ADO.NET连接,并通过自定义API方法公开对存储过程的调用吗? Something like a "GetStoredProcedure" controller method? 类似于“ GetStoredProcedure”控制器方法? Or do the APIs act like stored procedures? 还是API就像存储过程一样?

By .NET backend they are talking about a custom mobile service, which effectively in no different in terms of structure of a WebService using ADO.NET. 通过.NET后端,他们正在谈论自定义移动服务,该服务实际上在使用ADO.NET的WebService的结构上没有什么不同。 You would expose methods of the API to perform whatever functions you need to expose. 您将公开API的方法以执行需要公开的任何功能。

Typically, such methods would be GetCustomers, SaveCustomer, DeleteCustomer, etc. and would provide an appropriate implementation to satisfy that requirement. 通常,此类方法将是GetCustomers,SaveCustomer,DeleteCustomer等,并将提供适当的实现来满足该要求。 For example, GetCustomers may call a stored procedure that returns all the customers but could be any other SQL related operation. 例如,GetCustomers可以调用一个存储过程,该存储过程返回所有客户,但可以是任何其他与SQL相关的操作。 Typically there would be no generic methods such as 'GetStoredProcedure' as for me, this isn't a recommended approach. 通常,对于我而言,将不会有诸如“ GetStoredProcedure”之类的通用方法,因此不建议这样做。 For instance you may have business logic / data rules that would be applied rather than the consumer (your mobile service) from interacting with the backend DB directly - ultimately that's a trade-off of n-tiered systems, which has loads of discussion knocking around on the web, but just think of it in terms of whether you want to expose that kind of access to the DB... 例如,您可能具有将应用的业务逻辑/数据规则,而不是消费者(您的移动服务)直接与后端DB进行交互-最终,这是n层系统的权衡,需要进行大量讨论在网络上,但只要考虑是否要公开对数据库的访问权限即可...

Finally, on "do the APIs act like stored procedures", well this is rather subjective. 最后,关于“ API的行为就像存储过程一样”,这是相当主观的。 In terms of pure SQL they are chunks of T-SQL that can be called through a single entry point - so in those terms, they kinda do. 就纯SQL而言,它们是可以通过单个入口点调用的T-SQL块-因此,它们确实可以做到。 In more practical terms and more related to your overall question, a method exposed through a WebService or other .NET enabled endpoint, then you're only limited by the confines of .NET, so this could be calling and serving an explicit stored procedure returning strongly typed objects, it could be a file / blob operation or whatever technology operation you want (and are capable) to perform! 从更实际的角度讲,与您的总体问题更相关,该方法是通过WebService或其他启用.NET的终结点公开的,然后,您仅受.NET的限制,因此这可能是在调用并提供显式存储过程,并返回强类型对象,它可以是文件/ Blob操作,也可以是您想要(并且有能力)执行的任何技术操作!

HTH HTH

Glenn Gailey of the Microsoft Azure team wrote up a very useful blog post for this question HERE . Microsoft Azure团队的Glenn Gailey在此处针对此问题撰写了非常有用的博客文章。 It helped me create and call a stored procedure from the MobileService. 它帮助我从MobileService创建和调用存储过程。

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

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