本文整理汇总了C#中EntityQuery.GetResourcePath方法的典型用法代码示例。如果您正苦于以下问题:C# EntityQuery.GetResourcePath方法的具体用法?C# EntityQuery.GetResourcePath怎么用?C# EntityQuery.GetResourcePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityQuery
的用法示例。
在下文中一共展示了EntityQuery.GetResourcePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomersStartingWith
public async Task CustomersStartingWith() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Customer>("CustomersStartingWith").WithParameter("companyName", "A");
var rp = q.GetResourcePath(em1.MetadataStore);
var customers = await q.Execute(em1);
Assert.IsTrue(customers.Count() > 0, "should be some results");
Assert.IsTrue(customers.All(c => c.CompanyName.StartsWith("A")));
}
示例2: CustomersStartingWith
public async Task CustomersStartingWith() {
await _emTask;
var q = new EntityQuery<Customer>("CustomersStartingWith").WithParameter("companyName", "A");
var rp = q.GetResourcePath();
var customers = await q.Execute(_em1);
Assert.IsTrue(customers.Count() > 0, "should be some results");
Assert.IsTrue(customers.All(c => c.CompanyName.StartsWith("A")));
}
示例3: CompanyNamesAndIds
public async Task CompanyNamesAndIds() {
await _emTask;
var q = new EntityQuery<Object>("CompanyNamesAndIds");
var rp = q.GetResourcePath();
var companyNamesAndIds = await q.Execute(_em1);
Assert.IsTrue(companyNamesAndIds.Count() > 0, "should be some results");
// each item is a JObject
var companyNamesAndIdObjects = companyNamesAndIds.Cast<JObject>();
var item = companyNamesAndIdObjects.First();
var companyName = item["CompanyName"].ToObject<String>();
var id = item["CustomerID"].ToObject<Guid>();
}
示例4: CompanyNames
public async Task CompanyNames() {
await _emTask;
var q = new EntityQuery<String>("CompanyNames");
var rp = q.GetResourcePath();
var companyNames = await q.Execute(_em1);
Assert.IsTrue(companyNames.Count() > 0, "should be some results");
var q2 = new EntityQuery<Object>("CompanyNames");
rp = q2.GetResourcePath();
var companyNames2 = await q2.Execute(_em1);
Assert.IsTrue(companyNames2.Count() > 0, "should be some results");
Assert.IsTrue(companyNames.SequenceEqual(companyNames2.Cast<String>()));
}
示例5: CustomersWithHttpError
public async Task CustomersWithHttpError() {
await _emTask;
var q = new EntityQuery<Customer>("CustomersWithHttpError");
var rp = q.GetResourcePath();
try {
var results = await q.Execute(_em1);
Assert.Fail("shouldn't get here");
} catch (HttpRequestException e) {
Assert.IsTrue(e.Message.Contains("Custom Reason"));
Assert.IsTrue(e.Message.Contains("404"));
}
}
示例6: SearchCustomersWithParameters
public async Task SearchCustomersWithParameters() {
await _emTask;
//var query = EntityQuery.from("SearchCustomers")
// .withParameters( { CompanyName: "A", ContactNames: ["B", "C"] , City: "Los Angeles" } );
var q = new EntityQuery<Customer>("SearchCustomers")
.WithParameters(new Dictionary<String, Object> {
{ "CompanyName", "A" },
{ "ContactNames", new String[] { "B", "C" }},
{ "City", "LosAngeles" }
});
var rp = q.GetResourcePath();
var results = await q.Execute(_em1);
Assert.IsTrue(results.Count() == 3, "should be 3 results");
Assert.IsTrue(_em1.GetEntities<Customer>().Count() > 0, "should have some customers");
}
示例7: CustomersAndOrders
public async Task CustomersAndOrders() {
await _emTask;
var q = new EntityQuery<Customer>("CustomersAndOrders").Where(c => c.CompanyName.StartsWith("A"));
var rp = q.GetResourcePath();
var results = await q.Execute(_em1);
Assert.IsTrue(results.Count() > 0, "should be some results");
Assert.IsTrue(_em1.GetEntities<Customer>().Count() > 0, "should have some customers");
Assert.IsTrue(_em1.GetEntities<Order>().Count() > 0, "should have some orders");
Assert.IsTrue(results.All(c => c.CompanyName.StartsWith("A")));
}
示例8: CustomersWithBigOrders2
public async Task CustomersWithBigOrders2() {
await _emTask;
var q = new EntityQuery<CustomerAndBigOrders>("CustomersWithBigOrders");
var rp = q.GetResourcePath();
var results = await q.Execute(_em1);
Assert.IsTrue(results.Count() > 0, "should be some results");
Assert.IsTrue(_em1.GetEntities<Customer>().Count() > 0, "should have some customers");
Assert.IsTrue(_em1.GetEntities<Order>().Count() > 0, "should have some orders");
Assert.IsTrue(results.All(r =>
r.Customer.GetType() == typeof(Customer) && r.BigOrders.GetType() == typeof(List<Order>)
));
}
示例9: GuidQuery2
public async Task GuidQuery2() {
await _emTask;
var q = new EntityQuery<Order>().Where(o => o.CustomerID == Guid.NewGuid()); // && true);
var rp = q.GetResourcePath();
var r = await _em1.ExecuteQuery(q);
Assert.IsTrue(r.Count() == 0, "should be no results");
}
示例10: CustomersWithHttpError
public async Task CustomersWithHttpError() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Customer>("CustomersWithHttpError");
var rp = q.GetResourcePath(em1.MetadataStore);
try {
var results = await q.Execute(em1);
Assert.Fail("shouldn't get here");
}
catch (DataServiceRequestException e) {
Assert.IsTrue(e.ResponseContent.Contains("Custom error message"));
Assert.IsTrue(e.Message.ToLower().Contains("custom reason"));
}
catch (HttpRequestException) {
Assert.Fail("should not get here");
}
}
示例11: SearchCustomers
public async Task SearchCustomers() {
var em1 = await TestFns.NewEm(_serviceName);
//var query = EntityQuery.from("SearchCustomers")
// .withParameters( { CompanyName: "A", ContactNames: ["B", "C"] , City: "Los Angeles" } );
var q = new EntityQuery<Customer>("SearchCustomers")
.WithParameter("CompanyName", "A")
.WithParameter("ContactNames", new String[] { "B", "C" })
.WithParameter("City", "LosAngeles");
var rp = q.GetResourcePath(em1.MetadataStore);
var results = await q.Execute(em1);
Assert.IsTrue(results.Count() == 3, "should be 3 results");
Assert.IsTrue(em1.GetEntities<Customer>().Count() > 0, "should have some customers");
}
示例12: EmployeesFilteredByCountryAndBirthDate
public async Task EmployeesFilteredByCountryAndBirthDate() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Employee>().From("EmployeesFilteredByCountryAndBirthdate")
.WithParameter("birthDate", "1/1/1960")
.WithParameter("country", "USA");
var rp = q.GetResourcePath(em1.MetadataStore);
var results = await q.Execute(em1);
Assert.IsTrue(results.Any());
}
示例13: CustomersAndOrders
public async Task CustomersAndOrders() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Customer>("CustomersAndOrders").Where(c => c.CompanyName.StartsWith("A"));
var rp = q.GetResourcePath(em1.MetadataStore);
var results = await q.Execute(em1);
Assert.IsTrue(results.Count() > 0, "should be some results");
Assert.IsTrue(em1.GetEntities<Customer>().Count() > 0, "should have some customers");
Assert.IsTrue(em1.GetEntities<Order>().Count() > 0, "should have some orders");
Assert.IsTrue(results.All(c => c.CompanyName.StartsWith("A")));
}
示例14: CustomersWithBigOrders2
public async Task CustomersWithBigOrders2() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<CustomerAndBigOrders>("CustomersWithBigOrders");
var rp = q.GetResourcePath(em1.MetadataStore);
var results = await q.Execute(em1);
Assert.IsTrue(results.Count() > 0, "should be some results");
Assert.IsTrue(em1.GetEntities<Customer>().Count() > 0, "should have some customers");
Assert.IsTrue(em1.GetEntities<Order>().Count() > 0, "should have some orders");
Assert.IsTrue(results.All(r =>
r.Customer.GetType() == typeof(Customer) && r.BigOrders.GetType() == typeof(List<Order>)
));
}
示例15: CompanyNames
public async Task CompanyNames() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<String>("CompanyNames");
var rp = q.GetResourcePath(em1.MetadataStore);
var companyNames = await q.Execute(em1);
Assert.IsTrue(companyNames.Count() > 0, "should be some results");
var q2 = new EntityQuery<Object>("CompanyNames");
rp = q2.GetResourcePath(em1.MetadataStore);
var companyNames2 = await q2.Execute(em1);
Assert.IsTrue(companyNames2.Count() > 0, "should be some results");
Assert.IsTrue(companyNames.SequenceEqual(companyNames2.Cast<String>()));
}