本文整理汇总了C#中ODataClient类的典型用法代码示例。如果您正苦于以下问题:C# ODataClient类的具体用法?C# ODataClient怎么用?C# ODataClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataClient类属于命名空间,在下文中一共展示了ODataClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: CheckODataOrgNorthwindSchema
public void CheckODataOrgNorthwindSchema()
{
var client = new ODataClient("http://services.odata.org/Northwind/Northwind.svc/");
var table = client.Schema.FindTable("Product");
Assert.Equal("ProductID", table.PrimaryKey[0]);
var association = table.FindAssociation("Categories");
Assert.Equal("Categories", association.ReferenceTableName);
Assert.Equal("0..1", association.Multiplicity);
table = client.Schema.FindTable("Employees");
association = table.FindAssociation("Employees");
Assert.Equal("Employees", association.ReferenceTableName);
Assert.Equal("0..1", association.Multiplicity);
}
开发者ID:larsw,项目名称:Simple.OData,代码行数:16,代码来源:SchemaTest.cs
示例17: FilterWithMetadataDocument
public async Task FilterWithMetadataDocument()
{
var metadataDocument = await _client.GetMetadataDocumentAsync();
ODataClient.ClearMetadataCache();
var settings = new ODataClientSettings()
{
BaseUri = _serviceUri,
PayloadFormat = _payloadFormat,
MetadataDocument = metadataDocument,
};
var client = new ODataClient(settings);
var products = await client
.For("Products")
.Filter("Name eq 'Milk'")
.FindEntriesAsync();
Assert.Equal("Milk", products.Single()["Name"]);
}
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:17,代码来源:MetadataODataTests.cs
示例18: CheckPluralsightComSchema
public void CheckPluralsightComSchema()
{
var client = new ODataClient("http://pluralsight.com/odata/");
var table = client.Schema.FindTable("Modules");
Assert.AreEqual("Title", table.PrimaryKey[0]);
Assert.IsNotNull(table.FindColumn("Author"));
Assert.IsNotNull(table.FindColumn("Description"));
var association = table.FindAssociation("Course");
Assert.AreEqual("Courses", association.ReferenceTableName);
Assert.AreEqual("*", association.Multiplicity);
Assert.AreEqual(5, client.Schema.EntityTypes.Count());
Assert.AreEqual(0, client.Schema.ComplexTypes.Count());
}
开发者ID:nanohex,项目名称:Simple.OData.Client,代码行数:17,代码来源:SchemaTests.cs
示例19: CheckODataOrgODataSchema
public void CheckODataOrgODataSchema()
{
var client = new ODataClient("http://services.odata.org/V3/OData/OData.svc/");
var table = client.Schema.FindTable("Product");
Assert.AreEqual("ID", table.PrimaryKey[0]);
var association = table.FindAssociation("Category_Products");
Assert.AreEqual("Categories", association.ReferenceTableName);
Assert.AreEqual("*", association.Multiplicity);
var function = client.Schema.FindFunction("GetProductsByRating");
Assert.AreEqual(RestVerbs.GET, function.HttpMethod);
Assert.AreEqual("rating", function.Parameters[0]);
Assert.AreEqual(10, client.Schema.EntityTypes.Count());
Assert.AreEqual(1, client.Schema.ComplexTypes.Count());
Assert.AreEqual(5, client.Schema.ComplexTypes.First().Properties.Count());
}
开发者ID:khoale,项目名称:Simple.OData.Client,代码行数:19,代码来源:ClientTests.cs
示例20: CheckODataOrgNorthwindSchema
public async Task CheckODataOrgNorthwindSchema()
{
var client = new ODataClient("http://services.odata.org/V2/Northwind/Northwind.svc/");
var schema = await client.GetSchemaAsync();
var table = schema.FindTable("Product");
Assert.AreEqual("ProductID", table.PrimaryKey[0]);
var association = table.FindAssociation("Categories");
Assert.AreEqual("Categories", association.ReferenceTableName);
Assert.AreEqual("0..1", association.Multiplicity);
table = schema.FindTable("Employees");
association = table.FindAssociation("Employees");
Assert.AreEqual("Employees", association.ReferenceTableName);
Assert.AreEqual("0..1", association.Multiplicity);
Assert.AreEqual(26, schema.EntityTypes.Count());
Assert.AreEqual(0, schema.ComplexTypes.Count());
}
开发者ID:rmagruder,项目名称:Simple.OData.Client,代码行数:20,代码来源:SchemaTests.cs
注:本文中的ODataClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论