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


C# EntityQuery.Take方法代码示例

本文整理汇总了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");
    }
开发者ID:Cosmin-Parvulescu,项目名称:Breeze,代码行数:16,代码来源:LocalQueryTests.cs

示例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));
    }
开发者ID:Cosmin-Parvulescu,项目名称:Breeze,代码行数:16,代码来源:LocalQueryTests.cs

示例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);
    }
开发者ID:novice3030,项目名称:breeze.sharp,代码行数:11,代码来源:QueryTests.cs


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