本文整理汇总了C#中EntityQuery.With方法的典型用法代码示例。如果您正苦于以下问题:C# EntityQuery.With方法的具体用法?C# EntityQuery.With怎么用?C# EntityQuery.With使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityQuery
的用法示例。
在下文中一共展示了EntityQuery.With方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnonSelectEntityCollection
public async Task AnonSelectEntityCollection() {
var em1 = await TestFns.NewEm(_serviceName);
// precache the selected custs - needed to insure that local query works later.
var q0 = new EntityQuery<Foo.Customer>("Customers")
.Where(c => c.CompanyName.StartsWith("C"));
var r0 = await q0.With(em1).Execute();
var q2 = q0.Select(c => new { Orders = c.Orders });
var r2 = await q2.Execute(em1);
Assert.IsTrue(r2.Count() > 0);
var ok = r2.All(r1 => (r1.Orders.Count() > 0) && r1.Orders.All(o => o.GetType() == typeof(Foo.Order)));
Assert.IsTrue(ok, "every item of anon should contain a collection of Orders");
var r3Local = q2.ExecuteLocally(em1);
Assert.IsTrue(r3Local.Count() == r2.Count());
ok = r3Local.All(r1 => (r1.Orders.Count() > 0) && r1.Orders.All(o => o.GetType() == typeof(Foo.Order)));
Assert.IsTrue(ok, "every item of anon should contain a collection of Orders again");
}
示例2: StartsWithFetchStrategy
public async Task StartsWithFetchStrategy() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Foo.Customer>("Customers").Take(10);
var results = await em1.ExecuteQuery(q);
var q1 = new EntityQuery<Customer>().Where(c => c.CompanyName.StartsWith("C")).Take(3);
var r1 = await em1.ExecuteQuery(q1);
Assert.IsTrue(r1.Count() == 3);
// var r2 = em1.ExecuteQueryLocally(q1);
var r2 = await em1.ExecuteQuery(q1.With(FetchStrategy.FromLocalCache));
Assert.IsTrue(r1.Count() == r2.Count());
}