本文整理汇总了C#中EntityQuery.Take方法的典型用法代码示例。如果您正苦于以下问题:C# EntityQuery.Take方法的具体用法?C# EntityQuery.Take怎么用?C# EntityQuery.Take使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityQuery
的用法示例。
在下文中一共展示了EntityQuery.Take方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhereAnyOrderBy2
public async Task WhereAnyOrderBy2() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Foo.Customer>("Customers");
// just to fill up some extra custs
var rBase = await q.Take(10).Execute(em1);
var q2 = q.Where(c => c.CompanyName.StartsWith("C") && c.Orders.Any(o => o.Freight > 10));
var q3 = q2.OrderBy(c => c.City).Expand("Orders");
var r = await q3.Execute(em1);
Assert.IsTrue(r.Count() > 0);
Assert.IsTrue(r.All(r1 => r1.GetType() == typeof(Foo.Customer)), "should all get customers");
var rLocal = q3.ExecuteLocally(em1);
Assert.IsTrue(rLocal.Count() == r.Count());
Assert.IsTrue(r.SequenceEqual(rLocal), "should be in the same order");
}
示例2: WhereOrderByTake
public async Task WhereOrderByTake() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Foo.Customer>("Customers");
// to fill the cache
var r = await em1.ExecuteQuery(q.Take(5));
var q2 = q.Where(c => c.CompanyName.StartsWith("C"));
var q3 = q2.OrderBy(c => c.CompanyName).Take(2);
var r3 = await q3.Execute(em1);
Assert.IsTrue(r3.Count() == 2);
Assert.IsTrue(r3.All(r1 => r1.GetType() == typeof(Foo.Customer)), "should all get customers");
var r3Local = q3.ExecuteLocally(em1);
Assert.IsTrue(r3Local.SequenceEqual(r3));
}
示例3: NoWhere
public async Task NoWhere() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Customer>();
var results = await em1.ExecuteQuery(q);
Assert.IsTrue(results.Cast<Object>().Count() > 0);
var r1 = await em1.ExecuteQuery(q.Take(2));
Assert.IsTrue(r1.Count() == 2);
}