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


C# EntityQuery.Execute方法代码示例

本文整理汇总了C#中EntityQuery.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# EntityQuery.Execute方法的具体用法?C# EntityQuery.Execute怎么用?C# EntityQuery.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityQuery的用法示例。


在下文中一共展示了EntityQuery.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NullForeignKey

    public async Task NullForeignKey() {
      await _emTask;
      var prod1 = new Product();
      
      _em1.AttachEntity(prod1);
      prod1.ProductName = "Test";
      prod1.SupplierID = null;

      var q0 = new EntityQuery<Product>().Where(p => p.Supplier != null).Take(2).Expand(p => p.Supplier);
      var r0 = (await q0.Execute(_em1)).ToList();
      Assert.IsTrue(r0.Count() == 2);
      Assert.IsTrue(r0.All(p => p.Supplier != null));
      var p0 = r0[0];
      var p1 = r0[1];
      var s0 = p0.Supplier;
      var s1 = p1.Supplier;

      Assert.IsTrue(s0.Products.Contains(p0));
      p0.Supplier = null;
      Assert.IsTrue(p0.SupplierID == null);
      Assert.IsTrue(!s0.Products.Contains(p0));
      
      Assert.IsTrue(s1.Products.Contains(p1));
      p1.SupplierID = null;
      Assert.IsTrue(p1.Supplier == null);
      Assert.IsTrue(!s1.Products.Contains(p1));
    }
开发者ID:CodeLancer,项目名称:Breeze,代码行数:27,代码来源:AttachTests.cs

示例2: SaveCustomersAndNewOrder

    public async Task SaveCustomersAndNewOrder() {
      var em1 = await TestFns.NewEm(_serviceName);

      var q = new EntityQuery<Customer>("Customers").Where(c => c.CompanyName.StartsWith("A"));
      var custs = await q.Execute(em1);
      Assert.IsTrue(custs.Count() > 0, "should be some results");
      custs.ForEach(c => c.Fax = TestFns.MorphString(c.Fax));
      var cust1 = em1.CreateEntity<Customer>();
      cust1.CompanyName = "Test001";
      var cust1Key = cust1.EntityAspect.EntityKey;
      var order1 = em1.CreateEntity<Order>();
      var order1Key = order1.EntityAspect.EntityKey;

      order1.Customer = cust1;
      var custCount = em1.GetEntities<Customer>().Count();
      Assert.IsTrue(em1.HasChanges(), "hasChanges should be true");
      Assert.IsTrue(em1.GetChanges().Count() > 0, "should have changes");
      var saveResult = await em1.SaveChanges();
      Assert.IsTrue(saveResult.Entities.Count == custs.Count() + 2, "should have returned the correct number of entities");
      Assert.IsTrue(order1Key != order1.EntityAspect.EntityKey, "order1 entityKey should have changed");
      Assert.IsTrue(cust1Key != cust1.EntityAspect.EntityKey, "cust1 entityKey should have changed");
      Assert.IsTrue(order1.Customer == cust1, "cust attachment should be the same");
      Assert.IsTrue(cust1.Orders.Contains(order1), "order attachment should be the same");
      Assert.IsTrue(saveResult.KeyMappings[order1Key] == order1.EntityAspect.EntityKey, "keyMapping for order should be avail");
      Assert.IsTrue(saveResult.KeyMappings[cust1Key] == cust1.EntityAspect.EntityKey, "keyMapping for order should be avail");
      Assert.IsTrue(em1.GetEntities<Customer>().Count() == custCount, "should be the same number of custs");
      Assert.IsTrue(order1.EntityAspect.EntityState.IsUnchanged());
      Assert.IsTrue(cust1.EntityAspect.EntityState.IsUnchanged());
      Assert.IsTrue(em1.HasChanges() == false, "hasChanges should be false");
      Assert.IsTrue(em1.GetChanges().Count() == 0, "should be no changes left");
    }
开发者ID:Cosmin-Parvulescu,项目名称:Breeze,代码行数:31,代码来源:SaveTests.cs

示例3: 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")));

    }
开发者ID:novice3030,项目名称:Breeze,代码行数:10,代码来源:NamedQueryTests.cs

示例4: 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")));

    }
开发者ID:novice3030,项目名称:breeze.sharp,代码行数:10,代码来源:NamedQueryTests.cs

示例5: LoadNavigationPropertyNonscalar

 public async Task LoadNavigationPropertyNonscalar() {
   var em1 = await TestFns.NewEm(_serviceName);
   TestFns.RunInWpfSyncContext( async () =>  {
     var q0 = new EntityQuery<Customer>().Where(c => c.Orders.Any()).Take(3);
     var r0 = await q0.Execute(em1);
     // Task.WaitAll(r0.Select(c => c.EntityAspect.LoadNavigationProperty("Orders")).ToArray());
     await Task.WhenAll(r0.Select(c => c.EntityAspect.LoadNavigationProperty("Orders")));
     Assert.IsTrue(r0.All(c => c.Orders.Count() > 0));
   });
 }
开发者ID:Cosmin-Parvulescu,项目名称:Breeze,代码行数:10,代码来源:EntityManagerTests.cs

示例6: SimpleSelect2

    public async Task SimpleSelect2() {
      await _emTask;

      var q1 = new EntityQuery<Customer>().Where(c => c.CompanyName.StartsWith("C")).Expand("Orders").Select(c => c.Orders);
      var r1 = await q1.Execute(_em1);
      Assert.IsTrue(r1.Count() > 0);
      //var ok = r1.All(c => c.GetType() == typeof(Customer));
      //Assert.IsTrue(ok);


    }
开发者ID:BKlemm,项目名称:mean-seed,代码行数:11,代码来源:QueryTests.cs

示例7: SimpleSelect

    public async Task SimpleSelect() {
      await _emTask;

      var q1 = new EntityQuery<Order>().Select(o => o.Customer).Take(5);
      var r1 = await q1.Execute(_em1);
      Assert.IsTrue(r1.Count() == 5);
      var ok = r1.All(c => c.GetType() == typeof(Customer));
      Assert.IsTrue(ok);


    }
开发者ID:BKlemm,项目名称:mean-seed,代码行数:11,代码来源:QueryTests.cs

示例8: SimpleAnonEntityCollectionSelect

    public async Task SimpleAnonEntityCollectionSelect() {
      await _emTask;

      var q1 = new EntityQuery<Customer>().Where(c => c.CompanyName.StartsWith("C")).Select(c => new { c.Orders });
      var r1 = await q1.Execute(_em1);
      Assert.IsTrue(r1.Count() > 0);
      var ok = r1.All(r => r.Orders.Count() > 0);
      Assert.IsTrue(ok);


    }
开发者ID:CodeLancer,项目名称:Breeze,代码行数:11,代码来源:QueryTests.cs

示例9: 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>();
 }
开发者ID:novice3030,项目名称:Breeze,代码行数:12,代码来源:NamedQueryTests.cs

示例10: SimpleEntitySelect

    public async Task SimpleEntitySelect() {
      Assert.Inconclusive("Known issue with OData - use an anon projection instead");
      await _emTask;
      
      var q1 = new EntityQuery<Order>().Where(o => true).Select(o => o.Customer).Take(5);
      var r1 = await q1.Execute(_em1);
      Assert.IsTrue(r1.Count() == 5);
      var ok = r1.All(r => r.GetType() == typeof(Customer));
      Assert.IsTrue(ok);


    }
开发者ID:CodeLancer,项目名称:Breeze,代码行数:12,代码来源:QueryTests.cs

示例11: ExpEntities

    public async Task ExpEntities() {
      var em1 = await TestFns.NewEm(_serviceName);

      var q = new EntityQuery<Foo.Customer>("Customers").Take(5);

      var results = await q.Execute(em1);

      Assert.IsTrue(results.Count() > 0);
      var exportedEntities = em1.ExportEntities();

      File.WriteAllText("c:/temp/emExport.txt", exportedEntities);

    }
开发者ID:Cosmin-Parvulescu,项目名称:Breeze,代码行数:13,代码来源:ExportImportTests.cs

示例12: ExpEntities

    public async Task ExpEntities() {
      await _emTask;

      var q = new EntityQuery<Foo.Customer>("Customers").Take(5);

      var results = await q.Execute(_em1);

      Assert.IsTrue(results.Count() > 0);
      var exportedEntities = _em1.ExportEntities();

      File.WriteAllText("c:/temp/emExport.txt", exportedEntities);

    }
开发者ID:CodeLancer,项目名称:Breeze,代码行数:13,代码来源:ExportImportTests.cs

示例13: 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>()));
    }
开发者ID:novice3030,项目名称:Breeze,代码行数:14,代码来源:NamedQueryTests.cs

示例14: ExpEntitiesWithChanges

    public async Task ExpEntitiesWithChanges() {
      var em1 = await TestFns.NewEm(_serviceName);

      var q = new EntityQuery<Foo.Customer>("Customers").Take(5);

      var results = await q.Execute(em1);

      Assert.IsTrue(results.Count() > 0);
      var custs = results.Take(2);
      custs.ForEach(c => c.City = "Paris");
      var emp1 = em1.CreateEntity<Employee>();

      var exportedEntities = em1.ExportEntities();

      File.WriteAllText("c:/temp/emExportWithChanges.txt", exportedEntities);

    }
开发者ID:Cosmin-Parvulescu,项目名称:Breeze,代码行数:17,代码来源:ExportImportTests.cs

示例15: ExpImpEntitiesWithEnum

	public async Task ExpImpEntitiesWithEnum()
	{
      var em1 = await TestFns.NewEm(_serviceName);

      var q = new EntityQuery<Foo.Role>("Roles").Take(5);

      var results = await q.Execute(em1);

      Assert.IsTrue(results.Any());
      var exportedEntities = em1.ExportEntities();

      File.WriteAllText("c:/temp/emExportWithEnum.txt", exportedEntities);

      var em2 = new EntityManager(em1);

      em2.ImportEntities(exportedEntities);
      var roleTypes = em2.GetEntities<Role>().Select(x => x.RoleType).ToList();

	  Assert.IsTrue(roleTypes.Count == 5, "should have imported 5 entities");
	}
开发者ID:hiddenboox,项目名称:breeze.sharp,代码行数:20,代码来源:ExportImportTests.cs


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