OData V4 series. net applications, odatav4

Source: Internet
Author: User

OData V4 series. net applications, odatav4

OData learning directory

Add OData Client Code Generator Extension

Add OData T4 Generation Tool

Modify the MetadataDocumentUri of the T4 Template

Run the Web project, and then save the T4 template again. After the template is saved successfully, a proxy class (Ensure that the project is running or the project is published to IIS to ensure that the URL can be accessed normally.)

The operation code is as follows:

static void Main(string[] args)        {            const string serviceUri = "http://localhost:1088/OData";            var container = new Container(new Uri(serviceUri));            GetProducts(container);            var pro = new Product {Name = "Client OData", Price = 1024, Category = "IT"};            container.AddToProducts(pro);            pro = new Product { Name = "Client OData", Price = 1024, Category = "IT" };            container.AddToProducts(pro);            var list = container.Products.Where(c=>c.Id==1).ToList();            var proUpdate = list.FirstOrDefault();            if (proUpdate != null)            {                proUpdate.Name = "Update Client OData";            }            container.UpdateObject(proUpdate);            container.AddAndUpdateResponsePreference = DataServiceResponsePreference.IncludeContent;            // Add the data to the server            var response = container.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);            foreach (var operationResponse in response)            {                Console.WriteLine("Response: {0}", operationResponse.StatusCode);            }            Console.ReadLine();        }

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.