In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use the ADO.NET data service framework". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the ADO.NET data service framework.
Service operations can be used in situations where business logic is required, such as when implementing validation logic or security. Service operations allow developers to define a method on a server identified by URI (similar to other ADO.NET data service resources). These service operations are methods added to classes derived from the DataService that represent the data service.
Creation service operation of ADO.NET data service framework
To implement a service operation, define a public instance method as part of a data service class derived from the DataService class that represents the data service.
◆ this method can only accept the [in] parameter.
◆ if parameters are defined, the type of each parameter must be a primitive type.
◆ this method must return void, IEnumerable, IQueryable, T, or primitive classes such as integers or strings.
◆ T must be a class that represents an entity type in the data model that the data service will expose.
◆ to support query options such as sorting, paging, and filtering, the service action method should return IQueryable.
◆ must annotate this method with the [WebGet] or [WebInvoke] attributes.
◆ [WebGet] enables you to call this method by using a GET request.
◆ [WebInvoke] enables you to call this method by using a PUT, POST, or DELETE request.
You can use SingleResultAttribute to annotate service operations, specifying that the return value of this method is an entity rather than a set of entities. This distinction determines the serialization of the generated response. For example, when using AtomPub serialization, a single instance of a resource type is represented as an entry element, and a single instance set is represented as a feed element. If a method does not follow the convention defined above, the method is not exposed as a service operation in the data service. Address the service operation.
According to the ADO.NET data service protocol specification, service operations can be addressed by placing the name of the method in * path segments of the URI. You can add additional path segments or query options to this URI, depending on the return type of the service operation. The following example implements service operations for a data service that exposes a model based on an entity framework.
Public class Northwind: DataService {public static void InitializeService (IDataServiceConfiguration config) {/ / Entity sets access configuration. Config.SetEntitySetAccessRule ("*", EntitySetRights.AllRead) / / Service operations access configuration. Config.SetServiceOperationAccessRule ("OrdersByCity", ServiceOperationRights.All);} [WebGet] public IQueryable OrdersByCity (string city) {if (string.IsNullOrEmpty (city)) {throw new ArgumentNullException ("city", "You must provide a city name argument");} return this.CurrentDataSource.Orders.Where ("it.ShipCity = @ city", new ObjectParameter ("city", city)) }} Thank you for reading, the above is the content of "how to use the ADO.NET data service framework". After the study of this article, I believe you have a deeper understanding of how to use the ADO.NET data service framework, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.