当前位置: 首页>>代码示例>>C#>>正文


C# ODataClient类代码示例

本文整理汇总了C#中ODataClient的典型用法代码示例。如果您正苦于以下问题:C# ODataClient类的具体用法?C# ODataClient怎么用?C# ODataClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ODataClient类属于命名空间,在下文中一共展示了ODataClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EntityTracker

        internal EntityTracker(ODataClient oDataClient, object entity)
        {
            Contract.Requires<ArgumentNullException>(oDataClient != null);
            Contract.Requires<ArgumentNullException>(entity != null);

            _oDataClient = oDataClient;
            _entity = entity;
            _entityTypeInfo = oDataClient.GetEntityTypeInfoFor(entity.GetType());

            if (_entityTypeInfo == null)
            {
                throw new ArgumentException("Entity type " + entity.GetType() + " is unknown in the OData Client.");
            }

            _linkCollectionTrackers = new LinkCollectionTracker[_entityTypeInfo.CollectionProperties.Length];
            for (int i = 0; i < _entityTypeInfo.CollectionProperties.Length; ++i)
            {
                PropertyInfo property = _entityTypeInfo.CollectionProperties[i];
                IEnumerable collection = (IEnumerable) property.GetValue(_entity, null);
                if (collection != null)
                {
                    _linkCollectionTrackers[i] = new LinkCollectionTracker(this, property.Name, collection);
                }
            }

            INotifyPropertyChanged inpc = _entity as INotifyPropertyChanged;
            if (inpc != null)
            {
                // Use change tracking for more efficiency (possibly)
                inpc.PropertyChanged += OnPropertyChanged;
            }
        }
开发者ID:entityrepository,项目名称:ODataClient,代码行数:32,代码来源:EntityTracker.cs

示例2: FindEntryNuGetV1

 public async Task FindEntryNuGetV1()
 {
     var client = new ODataClient("http://nuget.org/api/v1");
     var package = await client.FindEntryAsync("Packages?$filter=Title eq 'EntityFramework'");
     Assert.NotNull(package["Id"]);
     Assert.NotNull(package["Authors"]);
 }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:7,代码来源:FindNuGetTests.cs

示例3: FindAllPeople

        public async Task FindAllPeople()
        {
            var client = new ODataClient(new ODataClientSettings
            {
                BaseUri = _serviceUri,
                IncludeAnnotationsInResults = true
            });
            var annotations = new ODataFeedAnnotations();

            int count = 0;
            var people = await client
                .For<PersonWithAnnotations>("Person")
                .FindEntriesAsync(annotations);
            count += people.Count();

            while (annotations.NextPageLink != null)
            {
                people = await client
                    .For<PersonWithAnnotations>()
                    .FindEntriesAsync(annotations.NextPageLink, annotations);
                count += people.Count();

                foreach (var person in people)
                {
                    Assert.NotNull(person.Annotations.Id);
                    Assert.NotNull(person.Annotations.ReadLink);
                    Assert.NotNull(person.Annotations.EditLink);
                }
            }

            Assert.Equal(count, annotations.Count);
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:32,代码来源:TripPinTests.cs

示例4: RetrieveSchemaFromUrlWithoutFilename

        public void RetrieveSchemaFromUrlWithoutFilename()
        {
            var client = new ODataClient("http://vancouverdataservice.cloudapp.net/v1/impark");

            var schema = client.Schema;

            Assert.IsTrue(schema.Tables.Any());
        }
开发者ID:nanohex,项目名称:Simple.OData.Client,代码行数:8,代码来源:SchemaTests.cs

示例5: TypedCombinedConditionsFromODataOrg

        public void TypedCombinedConditionsFromODataOrg()
        {
			var client = new ODataClient("http://services.odata.org/V2/OData/OData.svc/");
            var product = client
                .For<ODataOrgProduct>("Product")
                .Filter(x => x.Name == "Bread" && x.Price < 1000)
                .FindEntry();
            Assert.AreEqual(2.5m, product.Price);
        }
开发者ID:khoale,项目名称:Simple.OData.Client,代码行数:9,代码来源:ClientTests.cs

示例6: AddProduct

 static void AddProduct(Default.Container container, ODataClient.OData.Models.Product product)
 {
     container.AddToProducts(product);
     var serviceResponse = container.SaveChanges();
     foreach (var operationResponse in serviceResponse)
     {
         Console.WriteLine("Response: {0}", operationResponse.StatusCode);
     }
 }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:9,代码来源:Program.cs

示例7: AllEntriesFromODataOrg

 public void AllEntriesFromODataOrg()
 {
     var client = new ODataClient("http://services.odata.org/V3/OData/OData.svc/");
     var products = client
         .For("Product")
         .FindEntries();
     Assert.IsNotNull(products);
     Assert.AreNotEqual(0, products.Count());
 }
开发者ID:khoale,项目名称:Simple.OData.Client,代码行数:9,代码来源:ClientTests.cs

示例8: CombinedConditionsFromODataOrg

 public void CombinedConditionsFromODataOrg()
 {
     var client = new ODataClient("http://services.odata.org/V3/OData/OData.svc/");
     var x = ODataFilter.Expression;
     var product = client
         .For("Product")
         .Filter(x.Name == "Bread" && x.Price < 1000)
         .FindEntry();
     Assert.Equal(2.5m, product["Price"]);
 }
开发者ID:nanohex,项目名称:Simple.OData.Client,代码行数:10,代码来源:FindDynamicFilterTests.cs

示例9: GetEntryNonExistingIgnoreException

 public void GetEntryNonExistingIgnoreException()
 {
     var settings = new ODataClientSettings
     {
         UrlBase = _serviceUri,
         IgnoreResourceNotFoundException = true,
     };
     var client = new ODataClient(settings);
     Assert.Null(client.GetEntry("Products", new Entry() { { "ProductID", -1 } }));
 }
开发者ID:nanohex,项目名称:Simple.OData.Client,代码行数:10,代码来源:ClientTests.cs

示例10: SyncWithAllFailures

 public void SyncWithAllFailures()
 {
     using (var batch = new ODataBatch(_serviceUri))
     {
         var client = new ODataClient(batch);
         client.InsertEntry("Products", new Entry() { { "UnitPrice", 10m } }, false);
         client.InsertEntry("Products", new Entry() { { "UnitPrice", 20m } }, false);
         Assert.Throws<WebRequestException>(() => batch.Complete());
     }
 }
开发者ID:rmagruder,项目名称:Simple.OData.Client,代码行数:10,代码来源:BatchTests.cs

示例11: AsyncWithPartialFailures

 public async Task AsyncWithPartialFailures()
 {
     using (var batch = new ODataBatch(_serviceUri))
     {
         var client = new ODataClient(batch);
         await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test1" }, { "UnitPrice", 10m } }, false);
         await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test2" }, { "UnitPrice", 10m }, { "SupplierID", 0xFFFF } }, false);
         Assert.Throws<WebRequestException>(() => batch.Complete());
     }
 }
开发者ID:rmagruder,项目名称:Simple.OData.Client,代码行数:10,代码来源:BatchTests.cs

示例12: DynamicCombinedConditionsFromODataOrg

        public void DynamicCombinedConditionsFromODataOrg()
        {
			var client = new ODataClient("http://services.odata.org/V2/OData/OData.svc/");
			var x = ODataDynamic.Expression;
			var product = client
				.For(x.Product)
				.Filter(x.Name == "Bread" && x.Price < 1000)
				.FindEntry();
			Assert.AreEqual(2.5m, product.Price);
        }
开发者ID:rmagruder,项目名称:Simple.OData.Client,代码行数:10,代码来源:ClientTests.cs

示例13: AllEntriesFromODataOrg

		public void AllEntriesFromODataOrg()
        {
			AsyncContext.Run (async () => 
				{
					var client = new ODataClient("http://services.odata.org/V3/OData/OData.svc/");
					var products = await client
						.For("Product")
						.FindEntriesAsync();
					Assert.IsNotNull(products);
					Assert.AreNotEqual(0, products.Count());
				});
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:12,代码来源:ClientTests.cs

示例14: FindSinglePersonWithEntryAnnotations

        public async Task FindSinglePersonWithEntryAnnotations()
        {
            var client = new ODataClient(new ODataClientSettings
            {
                BaseUri = _serviceUri,
                IncludeAnnotationsInResults = true
            });
            var person = await client
                .For<PersonWithAnnotations>("Person")
                .Filter(x => x.UserName == "russellwhyte")
                .FindEntryAsync();

            Assert.NotNull(person.Annotations.Id);
        }
开发者ID:adestis-mh,项目名称:Simple.OData.Client,代码行数:14,代码来源:TripPinTests.cs

示例15: AsyncWithSuccess

        public async Task AsyncWithSuccess()
        {
            using (var batch = new ODataBatch(_serviceUri))
            {
                var client = new ODataClient(batch);
                await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test1" }, { "UnitPrice", 10m } }, false);
                await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test2" }, { "UnitPrice", 20m } }, false);
                batch.Complete();
            }

            var product = await _client.FindEntryAsync("Products?$filter=ProductName eq 'Test1'");
            Assert.NotNull(product);
            product = await _client.FindEntryAsync("Products?$filter=ProductName eq 'Test2'");
            Assert.NotNull(product);
        }
开发者ID:rmagruder,项目名称:Simple.OData.Client,代码行数:15,代码来源:BatchTests.cs


注:本文中的ODataClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。