zoukankan      html  css  js  c++  java
  • OData V4 系列 .net应用

          OData 学习目录

         添加 OData Client Code Generator 扩展

         

          

      添加OData T4生成工具

         

            修改 T4 模板的 MetadataDocumentUri

           

            运行Web项目,之后重新保存 T4模板,保存成功后会生成代理类  (必须保证项目运行或把项目发布到IIS,保证URL可以正常访问

           

             操作代码如下:        

    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();
    
            }
  • 相关阅读:
    文件系统
    Java的日志模块
    SQL Server 的索引结构实例
    SQL索引优化
    索引最佳实践
    SQL优化基础 使用索引(一个小例子)
    v使用索引的注意事项及常见场景、案例
    使用索引的注意事项及常见场景、案例
    SQL性能优化十条经验
    如何使用JVisualVM进行性能分析
  • 原文地址:https://www.cnblogs.com/Fengger/p/4959105.html
Copyright © 2011-2022 走看看