private async void ExecuteQuery() { var serviceName = "http://localhost:7150/breeze/NorthwindIBModel/"; var em = new EntityManager(serviceName); var query = "Employees"; // var metadata = await client.FetchMetadata(); var q = new EntityQuery<Foo.Customer>("Customers"); var q2 = q.Where(c => c.CompanyName.StartsWith("C") && c.Orders.Any(o => o.Freight > 10)); var q3 = q2.OrderBy(c => c.CompanyName).Skip(2); // var q3 = q2.Select(c => c.Orders); // fails // var q4 = q2.Select(c => new Dummy() { Orders = c.Orders} ); // var q4 = q2.Select(c => new { Orders = c.Orders }); // var q4 = q3.Select(c => new { c.CompanyName, c.Orders }); var x = await q3.Execute(em); //var q3 = q2.Expand(c => c.Orders); //var q4 = q3.OrderBy(c => c.CompanyName); //var zzz = q4.GetResourcePath(); //var x = await q4.Execute(em); var addresses = x.Select(c => { var z = c.CompanyName; var cid = c.CustomerID; c.CompanyName = "Test123"; return c.Address; }).ToList(); }
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)); }
public async Task QueryRoles() { //Assert.Inconclusive("See comments in the QueryRoles test"); // Issues: // // 1. When the RoleType column was not present in the Role entity in the database (NorthwindIB.sdf), // the query failed with "Internal Server Error". A more explanatory message would be nice. // The RoleType column has been added (nullable int), so this error no longer occurs. // // 2. Comment out the RoleType property in the client model (Model.cs in Client\Model_Northwind.Sharp project lines 514-517). // In this case, the client throws a null reference exception in CsdlMetadataProcessor.cs. // This is the FIRST problem reported by the user. A more informative message would be helpful. // // Note that this condition causes many other tests to fail as well. // // 3. Uncomment the RoleType property in the client model. Then the client throws in JsonEntityConverter.cs. // This is the SECOND problem reported by the user. This looks like a genuine bug that should be fixed. // var manager = new EntityManager(_serviceName); // Metadata must be fetched before CreateEntity() can be called await manager.FetchMetadata(); var query = new EntityQuery<Role>(); var allRoles = await manager.ExecuteQuery(query); Assert.IsTrue(allRoles.Any(), "There should be some roles defined"); }
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"); }
public async Task ParallelQueries() { var entityManager = new EntityManager(_serviceName); await entityManager.FetchMetadata(); var idQuery = new EntityQuery<Customer>(); var entities = await entityManager.ExecuteQuery(idQuery); var n = 20; var ids = entities.Select(c => c.CustomerID).Take(n).ToArray(); // In case there aren't n customers available var actualCustomers = ids.Count(); var numExecutions = 0; var tasks = ids.Select(id => { ++numExecutions; var query = new EntityQuery<Customer>().Where(c => c.CustomerID == ids[0]); return entityManager.ExecuteQuery(query); // Best practice is to apply ToList() or ToArray() to the task collection immediately // Realizing the collection more than once causes multiple executions of the anon method }).ToList(); var numTasks = tasks.Count(); // Result of WhenAll is an array of results from the individual anonymous method executions // Each individual result is a collection of customers // (only one in this case because of the condition on CustomerId) var results = await Task.WhenAll(tasks); var numCustomers = results.Sum(customers => customers.Count()); Assert.AreEqual(actualCustomers, numTasks, "Number of tasks should be " + actualCustomers + ", not " + numTasks); Assert.AreEqual(actualCustomers, numExecutions, "Number of excutions should be " + actualCustomers + ", not " + numExecutions); Assert.AreEqual(actualCustomers, numCustomers, actualCustomers + " customers should be returned, not " + numCustomers); }
public async Task CompositePred() { var entityManager = await TestFns.NewEm(_serviceName); // Start with a base query for all Orders var baseQuery = new EntityQuery<Order>(); // A Predicate is a condition that is true or false // Combine two predicates with '.And' to // query for orders with freight cost over $100 // that were ordered after April 1, 1998 var p1 = PredicateBuilder.Create<Order>(o => o.Freight > 100); var p2 = PredicateBuilder.Create<Order>(o => o.OrderDate > new DateTime(1998, 3, 1)); var pred = p1.And(p2); var query = baseQuery.Where(pred); var orders = await entityManager.ExecuteQuery(query); Assert.IsTrue(orders.Any(), "There should be orders"); Assert.IsTrue(orders.All(o => o.Freight > 100 && o.OrderDate > new DateTime(1998,3,1)), "There should be the right orders"); // Yet another way to ask the same question pred = PredicateBuilder.Create<Order>(o => o.Freight > 100) .And(PredicateBuilder.Create<Order>(o => o.OrderDate > new DateTime(1998, 3, 1))); var query2 = baseQuery.Where(pred); var orders2 = await entityManager.ExecuteQuery(query2); Assert.IsTrue(orders2.Count() == orders.Count()); // Yet another way to ask the same question pred = PredicateBuilder.Create<Order>(o => o.Freight > 100) .Or(PredicateBuilder.Create<Order>(o => o.OrderDate > new DateTime(1998, 3, 1))); var query3 = baseQuery.Where(pred); }
public EntityInfo TargetEntity; //for delete, insert, update #endregion Fields #region Constructors public LinqCommand(EntityQuery query, LinqCommandType commandType, LinqCommandKind kind, EntityInfo targetEntity) { Kind = kind; CommandType = commandType; Query = query; TargetEntity = targetEntity; }
public async Task SimpleConcurrencyFault() { Configuration.Instance.ProbeAssemblies(typeof(Customer).Assembly); // Query Alfred var entityManager1 = new EntityManager(_northwindServiceName); var query = new EntityQuery<Customer>().Where(c => c.CustomerID == _alfredsID); var alfred1 = (await entityManager1.ExecuteQuery(query)).FirstOrDefault(); // Query a second copy of Alfred in a second entity manager var entityManager2 = new EntityManager(_northwindServiceName); var alfred2 = (await entityManager2.ExecuteQuery(query)).FirstOrDefault(); // Modify and save the first Alfred alfred1.ContactTitle += "X"; // Currently, this throws due to "changes to an original record may not be saved" // ...whatever that means var saveResult1 = await entityManager1.SaveChanges(); // Attempt to modify and save the second Alfred alfred2.ContactName += "Y"; try { var saveResult2 = await entityManager2.SaveChanges(); } catch (SaveException e) { var message = e.Message; } }
// called by ObjectDataSource - set sort, grouping and filter info before calling load internal EntityQueryPagedCollectionView(EntityQuery query, int pageSize, int loadSize, SortDescriptionCollection sortDescriptors, ObservableCollection<GroupDescription> groupDescriptors, IPredicateDescription filter) : this(query, pageSize, loadSize, true, false) { sortDescriptors.ForEach(d => SortDescriptions.Add(d)); groupDescriptors.ForEach(d=> GroupDescriptions.Add(d)); SetQueryFilter(filter); Refresh(); }
public async Task RefreshAsync() { var query = new EntityQuery<Person>(); IEnumerable<Person> persons = await _entityManager.ExecuteQuery<Person>(query); Person = persons.FirstOrDefault(); // TODO: Also get distastes, make it part of the same query. }
public async Task SimpleQuery() { await _emTask; var q = new EntityQuery<Customer>(); var results = await _em1.ExecuteQuery(q); Assert.IsTrue(results.Cast<Object>().Count() > 0); }
public async Task WithOnlyExpand() { await _emTask; var q = new EntityQuery<Customer>().Take(3); var r0 = await _em1.ExecuteQuery(q); var q1 = new EntityQuery<Customer>().Expand("Orders"); var r1 = q1.ExecuteLocally(_em1); Assert.IsTrue(r0.Count() == r1.Count()); }
public async Task WithOnlyExpand() { var em1 = await TestFns.NewEm(_serviceName); var q = new EntityQuery<Customer>().Take(3); var r0 = await em1.ExecuteQuery(q); var q1 = new EntityQuery<Customer>().Expand("Orders"); var r1 = q1.ExecuteLocally(em1); Assert.IsTrue(r0.Count() == r1.Count()); }
public async Task QueryAbstractWithOr() { var em1 = await TestFns.NewEm(_serviceName); var q = new EntityQuery<Fruit>().From("Fruits").Where(f => f.Name == "Apple" || f.Name == "Foo" || f.Name == "Papa"); var r0 = await em1.ExecuteQuery(q); Assert.IsTrue(r0.Count() > 0); var fruit1 = r0.First(); Assert.IsTrue(fruit1 is Apple, "fruit should be an Apple"); }
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)); }); }
/// <summary> /// Initializes a new <see cref="WebDomainClientAsyncResult<TContract>"/> instance used for Query operations. /// </summary> /// <param name="callback">Optional <see cref="AsyncCallback"/> to invoke upon completion.</param> /// <param name="asyncState">Optional user state information that will be passed to the <paramref name="callback"/>.</param> /// <exception cref="ArgumentNullException">if <paramref name="domainClient"/> is null.</exception> /// <exception cref="ArgumentNullException">if <paramref name="endOperationMethod"/> is null.</exception> private WebApiDomainClientAsyncResult(WebApiDomainClient domainClient, EntityQuery query, AsyncCallback callback, object asyncState) : base(domainClient, callback, asyncState) { // base class validates domainClient if (query == null) throw new ArgumentNullException("query"); _interfaceType = domainClient.ServiceInterfaceType; _operationName = query.QueryName; }
public async Task SimplePred() { var entityManager = await TestFns.NewEm(_serviceName); // Orders with freight cost over 300. var pred = PredicateBuilder.Create<Order>(o => o.Freight > 300); var query = new EntityQuery<Order>().Where(pred); var orders300 = await entityManager.ExecuteQuery(query); Assert.IsTrue(orders300.Any(), "There should be orders with freight cost > 300"); }
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"))); }
public async Task SimpleQuery() { var em1 = await TestFns.NewEm(_serviceName); var q = new EntityQuery<Customer>(); var r0 = await em1.ExecuteQuery(q); Assert.IsTrue(r0.Cast<Object>().Count() > 0); var r1 = q.ExecuteLocally(em1); Assert.IsTrue(r0.Count() == r1.Count()); }
public async Task MetadataMissingClrPropertyQuery() { var em = new EntityManager(_serviceName); em.MetadataStore.NamingConvention = new MorphedClassNamingConvention(); em.MetadataStore.AllowedMetadataMismatchTypes = MetadataMismatchTypes.AllAllowable; var q = new EntityQuery<PartialFoo.Customer>().Where(c => c.CompanyName.StartsWith("B")); var r0 = await em.ExecuteQuery(q); Assert.IsTrue(r0.Count() > 0); }
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"))); }
public async Task SimpleQuery() { await _emTask; var q = new EntityQuery<Customer>(); var r0 = await _em1.ExecuteQuery(q); Assert.IsTrue(r0.Cast<Object>().Count() > 0); var r1 = q.ExecuteLocally(_em1); Assert.IsTrue(r0.Count() == r1.Count()); }
private static EntityQuery AddWhereClause(EntityQuery entityQuery, LambdaExpression lambda) { // This works too - not sure which is faster or better //var method = factory.GetType().GetMethod("Where", new Type[] { typeof(LambdaExpression) }); //var query = method.Invoke(factory, new Object[] { lambda }); //return (EntityQuery)query; var expr = BuildCallWhereExpr(entityQuery, lambda); var query = (EntityQuery)TypeFns.ConstructGenericInstance(typeof(EntityQuery<>), new Type[] { entityQuery.ElementType }, expr, entityQuery); return query; }
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); }
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); }
public async Task NonGenericQuery() { await _emTask; var q = new EntityQuery<Foo.Customer>("Customers"); var q2 = q.Where(c => c.CompanyName.StartsWith("C")).Take(3); var q3 = (EntityQuery)q2; var results = await _em1.ExecuteQuery(q3); Assert.IsTrue(results.Cast<Object>().Count() == 3); }
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); }
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); }
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>(); }
public async Task SimpleCall() { //return; var em1 = new EntityManager(_dataService); em1.MetadataStore.NamingConvention = new EdmundsNamingConvention(); Model.Edmunds.Config.Initialize(em1.MetadataStore); var initParameters = InitialParameters(); var q = new EntityQuery<Make>().From("vehicle/makerepository/findall") .WithParameters(initParameters).With(new EdmundsJsonResultsAdapter()); var r = await em1.ExecuteQuery(q); Assert.IsTrue(r.Any()); }
protected override void OnCreate() { m_query = GetEntityQuery(ComponentType.ReadOnly <CollectionComponentSystemStateTag <T> >(), ComponentType.Exclude(new T().AssociatedComponentType)); }
protected override void OnCreate() { // Cached access to a set of ComponentData based on a specific query group = GetEntityQuery(typeof(EnemyTag), typeof(BulletTag), typeof(Translation), typeof(Rotation) /*ComponentType.ReadOnly<Rotation>()*/, ComponentType.ReadOnly <MoveSpeed>()); }
private LoadOperation <Web.Model.taxpayer> LoadTaxPayerEntities() { EntityQuery <DocumentManager.Web.Model.taxpayer> lQuery = documentManagerContext.GetTaxpayerQuery(); return(documentManagerContext.Load(lQuery.SortAndPageBy(this.taxPayerView))); }
internal InsertQueryExecutor(EntityQuery <TBase> query, SqlConnection connection, SqlTransaction?transaction = null) : base(query, connection, transaction) { }
protected override void OnCreateManager() { _cubes = Entities .WithAll <RotationSpeed, Rotation>() .ToEntityQuery(); }
protected override void OnStartRunning() { this.sfxQuery = Entities.WithAll <SFX>().ToEntityQuery(); }
protected override void OnCreate() { dynamicQuery = GetEntityQuery( ComponentType.ReadWrite <RoomContentDynamicLinkSystemState>(), ComponentType.ReadWrite <RoomContent>()); }
protected override void OnCreate() { Group1 = GetEntityQuery(typeof(JustComponentNonExclude), ComponentType.Exclude <ZeroSizedComponent>()); Group2 = GetEntityQuery(typeof(JustComponentNonExclude), ComponentType.Exclude <NonZeroSizedComponent>()); }
void CastingHistoryReport_Completed(object sender, EventArgs e) { int foundryId = cmbFoundry.SelectedIndex == -1 ? -1 : ((Foundry)cmbFoundry.SelectedItem).ID; var coverageId = cmbCoverage.SelectedValue == null ? -1 : ((Coverage)cmbCoverage.SelectedValue).ID; List <FilmConsumptionReportRow> FilmConsumptionReportRowList = new List <FilmConsumptionReportRow>(); EntityQuery <FilmConsumptionReportRow> query = ctx.GetCastingHistoryReportQuery(foundryId, txtRTNo.Text, txtHeatNo.Text, txtFPNo.Text, coverageId); LoadOperation <FilmConsumptionReportRow> loadOp = ctx.Load(query, loadOpN => { foreach (var filmConsumptionReportRow in loadOpN.Entities) { FilmConsumptionReportRowList.Add(filmConsumptionReportRow); } if (FilmConsumptionReportRowList.Count > 0) { reportTable = new DataTable("Report"); var cols = reportTable.Columns; var rows = reportTable.Rows; var headerRow = new DataRow(); rows.Add(headerRow); var subHeaderRow = new DataRow(); rows.Add(subHeaderRow); AddTextColumn(reportTable, "ReportNo", "Report No"); AddTextColumn(reportTable, "ReportDate", "Report Date"); AddTextColumn(reportTable, "DateOfTest", "Date of Test"); AddTextColumn(reportTable, "RTNo", "RT No"); headerRow["ReportNo"] = "Report No"; headerRow["ReportDate"] = "Report Date"; headerRow["DateOfTest"] = "Date of Test"; headerRow["RTNo"] = "RT No"; subHeaderRow["ReportNo"] = ""; subHeaderRow["ReportDate"] = ""; subHeaderRow["DateOfTest"] = ""; subHeaderRow["RTNo"] = ""; int highestNoOfRepair = FilmConsumptionReportRowList.Select(p => p.ReshootNo).Max(); int rowIndexForFresh = 0; foreach (var row in ctx.Energies) { var colName = "Fresh" + row.Name; headerRow[colName] = rowIndexForFresh == 0 ? "Fresh " : string.Empty; AddTextColumn(reportTable, colName, colName); subHeaderRow[colName] = row.Name; rowIndexForFresh++; } //Repair columns for (int i = 0; i < highestNoOfRepair; i++) { int rowIndex = 0; foreach (var row in ctx.Energies) { var colName = "Repair" + (i + 1) + row.Name; AddTextColumn(reportTable, colName, colName); headerRow[colName] = rowIndex == 0 ? "Repair " + (i + 1) : string.Empty; subHeaderRow[colName] = row.Name; rowIndex++; } } //Reshoot columns for (int i = 0; i < highestNoOfRepair; i++) { int rowIndex = 0; foreach (var row in ctx.Energies) { var colName = "Reshoot" + (i + 1) + row.Name; AddTextColumn(reportTable, colName, colName); headerRow[colName] = rowIndex == 0 ? "Reshoot " + (i + 1) : string.Empty; subHeaderRow[colName] = row.Name; rowIndex++; } } //Retake columns for (int i = 0; i < highestNoOfRepair; i++) { int rowIndex = 0; foreach (var row in ctx.Energies) { var colName = "Retake" + (i + 1) + row.Name; AddTextColumn(reportTable, colName, colName); headerRow[colName] = rowIndex == 0 ? "Retake " + (i + 1) : string.Empty; subHeaderRow[colName] = row.Name; rowIndex++; } } //Retake columns for (int i = 0; i < highestNoOfRepair; i++) { int rowIndex = 0; foreach (var row in ctx.Energies) { var colName = "Checkshot" + (i + 1) + row.Name; AddTextColumn(reportTable, colName, colName); headerRow[colName] = rowIndex == 0 ? "Checkshot " + (i + 1) : string.Empty; subHeaderRow[colName] = row.Name; rowIndex++; } } int countForInnerLoop = 0; int noOfInnerLoops = FilmConsumptionReportRowList.Where(p => p.ReshootNo != 0).Count(); List <RGReport> rgReportList = new List <RGReport>(); foreach (var filmConsumptionReportRow in FilmConsumptionReportRowList) { if (filmConsumptionReportRow.ReshootNo == 0) { } else { EntityQuery <RGReport> queryInner = ctx.GetRGReportsOnRtNoAndReshootNoForReportQuery(filmConsumptionReportRow.RTNo, (filmConsumptionReportRow.ReshootNo - 1)); LoadOperation <RGReport> loadOpInner = ctx.Load(queryInner, loadOpNInner => { countForInnerLoop++; foreach (var rgReport in loadOpNInner.Entities) { rgReportList.Add(rgReport); } if (noOfInnerLoops == countForInnerLoop) { foreach (var filmConsumptionReportRowInner in FilmConsumptionReportRowList) { string prevReportNo = ""; DataRow dataRow = null; string prevEnergy = String.Empty; if (filmConsumptionReportRowInner.ReportNo != prevReportNo) { if (filmConsumptionReportRowInner.ReshootNo == 0) { dataRow = new DataRow(); dataRow["ReportNo"] = prevReportNo = filmConsumptionReportRowInner.ReportNo; //set prevReportNo for next time dataRow["ReportDate"] = filmConsumptionReportRowInner.Date; dataRow["DateOfTest"] = filmConsumptionReportRowInner.DateOfTest; dataRow["RTNo"] = filmConsumptionReportRowInner.RTNo; dataRow["FreshCo 60"] = filmConsumptionReportRowInner.AreaInCo; dataRow["FreshIr 192"] = filmConsumptionReportRowInner.AreaInIr; rows.Add(dataRow); } else { RGReport rgReport = rgReportList.Where(p => p.RTNo == filmConsumptionReportRowInner.RTNo && p.ReshootNo == (filmConsumptionReportRowInner.ReshootNo - 1)).FirstOrDefault(); float repairAreaCo = 0; float reshootAreaCo = 0; float retakeAreaCo = 0; float checkshotAreaCo = 0; float repairAreaIr = 0; float reshootAreaIr = 0; float retakeAreaIr = 0; float checkshotAreaIr = 0; if (rgReport != null) { foreach (RGReportRow reportRow in rgReport.RGReportRows) { if (reportRow.RemarkID == 1) { if (reportRow.EnergyID == 1) { repairAreaCo += reportRow.FilmSize.Area * reportRow.FilmCount; } else { repairAreaIr += reportRow.FilmSize.Area * reportRow.FilmCount; } } else if (reportRow.RemarkID == 3) { if (reportRow.EnergyID == 1) { reshootAreaCo += reportRow.FilmSize.Area * reportRow.FilmCount; } else { reshootAreaIr += reportRow.FilmSize.Area * reportRow.FilmCount; } } else if (reportRow.RemarkID == 4) { if (reportRow.EnergyID == 1) { retakeAreaCo += reportRow.FilmSize.Area * reportRow.FilmCount; } else { retakeAreaIr += reportRow.FilmSize.Area * reportRow.FilmCount; } } else if (reportRow.RemarkID == 5) { if (reportRow.EnergyID == 1) { checkshotAreaCo += reportRow.FilmSize.Area * reportRow.FilmCount; } else { checkshotAreaIr += reportRow.FilmSize.Area * reportRow.FilmCount; } } } } dataRow = new DataRow(); dataRow["ReportNo"] = prevReportNo = filmConsumptionReportRowInner.ReportNo; //set prevReportNo for next time dataRow["ReportDate"] = filmConsumptionReportRowInner.Date; dataRow["DateOfTest"] = filmConsumptionReportRowInner.DateOfTest; dataRow["RTNo"] = filmConsumptionReportRowInner.RTNo; dataRow["FreshCo 60"] = filmConsumptionReportRowInner.AreaInCo; dataRow["FreshIr 192"] = filmConsumptionReportRowInner.AreaInIr; foreach (var row in ctx.Energies) { if (row.ID == 1) { dataRow["Repair" + (filmConsumptionReportRowInner.ReshootNo) + row.Name] = repairAreaCo; dataRow["Reshoot" + (filmConsumptionReportRowInner.ReshootNo) + row.Name] = reshootAreaCo; dataRow["Retake" + (filmConsumptionReportRowInner.ReshootNo) + row.Name] = retakeAreaCo; dataRow["Checkshot" + (filmConsumptionReportRowInner.ReshootNo) + row.Name] = checkshotAreaCo; } else if (row.ID == 2) { dataRow["Repair" + (filmConsumptionReportRowInner.ReshootNo) + row.Name] = repairAreaIr; dataRow["Reshoot" + (filmConsumptionReportRowInner.ReshootNo) + row.Name] = reshootAreaIr; dataRow["Retake" + (filmConsumptionReportRowInner.ReshootNo) + row.Name] = retakeAreaIr; dataRow["Checkshot" + (filmConsumptionReportRowInner.ReshootNo) + row.Name] = checkshotAreaIr; rows.Add(dataRow); } } } } } //totals row var totalRow = new DataRow(); totalRow["FreshCo 60"] = rows.Select(p => (p["FreshCo 60"] as float?) ?? 0).Sum(); totalRow["FreshIr 192"] = rows.Select(p => (p["FreshIr 192"] as float?) ?? 0).Sum(); //Repair columns for (int i = 0; i < highestNoOfRepair; i++) { int rowIndex = 0; foreach (var row in ctx.Energies) { var colName = "Repair" + (i + 1) + row.Name; totalRow[colName] = rows.Select(p => (p[colName] as float?) ?? 0).Sum(); rowIndex++; } } //Reshoot columns for (int i = 0; i < highestNoOfRepair; i++) { int rowIndex = 0; foreach (var row in ctx.Energies) { var colName = "Reshoot" + (i + 1) + row.Name; totalRow[colName] = rows.Select(p => (p[colName] as float?) ?? 0).Sum(); rowIndex++; } } //Retake columns for (int i = 0; i < highestNoOfRepair; i++) { int rowIndex = 0; foreach (var row in ctx.Energies) { var colName = "Retake" + (i + 1) + row.Name; totalRow[colName] = rows.Select(p => (p[colName] as float?) ?? 0).Sum(); rowIndex++; } } //checkshot columns for (int i = 0; i < highestNoOfRepair; i++) { int rowIndex = 0; foreach (var row in ctx.Energies) { var colName = "Checkshot" + (i + 1) + row.Name; totalRow[colName] = rows.Select(p => (p[colName] as float?) ?? 0).Sum(); rowIndex++; } } rows.Add(totalRow); var ds = new DataSet("ReportDataSet"); ds.Tables.Add(reportTable); reportGrid.DataSource = ds; reportGrid.DataMember = "Report"; reportGrid.DataBind(); busyIndicator.IsBusy = false; } }, false); } } if (noOfInnerLoops == 0) { DataRow dataRow = null; foreach (var filmConsumptionReportRowInner in FilmConsumptionReportRowList) { dataRow = new DataRow(); dataRow["ReportNo"] = filmConsumptionReportRowInner.ReportNo; //set prevReportNo for next time dataRow["ReportDate"] = filmConsumptionReportRowInner.Date; dataRow["DateOfTest"] = filmConsumptionReportRowInner.DateOfTest; dataRow["RTNo"] = filmConsumptionReportRowInner.RTNo; dataRow["FreshCo 60"] = filmConsumptionReportRowInner.AreaInCo; dataRow["FreshIr 192"] = filmConsumptionReportRowInner.AreaInIr; rows.Add(dataRow); } var totalRow = new DataRow(); totalRow["FreshCo 60"] = rows.Select(p => (p["FreshCo 60"] as float?) ?? 0).Sum(); totalRow["FreshIr 192"] = rows.Select(p => (p["FreshIr 192"] as float?) ?? 0).Sum(); rows.Add(totalRow); var ds = new DataSet("ReportDataSet"); ds.Tables.Add(reportTable); reportGrid.DataSource = ds; reportGrid.DataMember = "Report"; reportGrid.DataBind(); busyIndicator.IsBusy = false; } } else { var ds = new DataSet("ReportDataSet"); reportTable = new DataTable("Report"); ds.Tables.Add(reportTable); reportGrid.DataSource = ds; reportGrid.DataMember = "Report"; reportGrid.DataBind(); MessageBox.Show("No records found!!"); busyIndicator.IsBusy = false; return; } }, false); }
protected override void OnCreate() { base.OnCreate(); bubblesQuery = GetEntityQuery(ComponentType.ReadOnly <BubbleCmp>()); }
protected override void OnCreate() { m_Group = GetEntityQuery(typeof(NodeSleeping)); m_GroupTimer = GetEntityQuery(typeof(NodeTimer), typeof(ActionRunState)); }
protected override void OnCreate() { m_GroupTimer = GetEntityQuery(typeof(ActionRunState)); }
protected override void Initialize(ref EntityQuery group) { // We copy to list of incoming hitcollisions as it is not allowed to add entities while iterating componentarray var hitCollisionArray = group.ToComponentArray <HitCollisionHistory>(); var hitCollisionEntityArray = group.GetEntityArraySt(); for (var iHitColl = 0; iHitColl < hitCollisionArray.Length; iHitColl++) { var hitCollision = hitCollisionArray[iHitColl]; var hitCollisionEntity = hitCollisionEntityArray[iHitColl]; var externalSetup = hitCollision.settings.collisionSetup != null; var colliderSetup = externalSetup ? hitCollision.settings.collisionSetup.transform : hitCollision.transform; // TODO (mogensh) cache and reuse collision setup from each prefab - or find better serialization format // Find and disable all all colliders on collisionOwner var sourceColliders = new List <Collider>(); RecursiveGetCollidersInChildren(colliderSetup.transform, sourceColliders); foreach (var collider in sourceColliders) { collider.enabled = false; } // Create collider collection if (m_systemRoot != null) { hitCollision.transform.SetParent(m_systemRoot.transform, false); } var uniqueParents = new List <Transform>(16); var colliderParents = new List <Transform>(16); var capsuleColliders = new List <CapsuleCollider>(16); var capsuleColliderParents = new List <Transform>(16); var sphereColliders = new List <SphereCollider>(16); var sphereColliderParents = new List <Transform>(16); var boxColliders = new List <BoxCollider>(16); var boxColliderParents = new List <Transform>(16); for (var i = 0; i < sourceColliders.Count; i++) { var sourceCollider = sourceColliders[i]; var colliderParentBone = sourceCollider.transform.parent; if (externalSetup) { var skeleton = EntityManager.GetComponentObject <Skeleton>(hitCollisionEntity); var ownerBoneIndex = skeleton.GetBoneIndex(colliderParentBone.name.GetHashCode()); colliderParentBone = skeleton.bones[ownerBoneIndex]; } colliderParents.Add(colliderParentBone); if (!uniqueParents.Contains(colliderParentBone)) { uniqueParents.Add(colliderParentBone); } var capsuleCollider = sourceCollider as CapsuleCollider; if (capsuleCollider != null) { capsuleColliderParents.Add(colliderParentBone); capsuleColliders.Add(capsuleCollider); } else { var boxCollider = sourceCollider as BoxCollider; if (boxCollider != null) { boxColliders.Add(boxCollider); boxColliderParents.Add(colliderParentBone); } else { var sphereCollider = sourceCollider as SphereCollider; if (sphereCollider != null) { sphereColliders.Add(sphereCollider); sphereColliderParents.Add(colliderParentBone); } } } } hitCollision.collisiderParents = new TransformAccessArray(uniqueParents.ToArray()); HitCollisionData.Setup(EntityManager, hitCollisionEntity, uniqueParents, hitCollision.settings.boundsRadius, hitCollision.settings.boundsHeight, capsuleColliders, capsuleColliderParents, sphereColliders, sphereColliderParents, boxColliders, boxColliderParents); } }
protected override void OnCreate() { playerQuery = GetEntityQuery(typeof(Player), ComponentType.ReadOnly <LocalToWorld>()); }
protected override void OnCreate() { base.OnCreate(); SpawnGroup = GetEntityQuery(typeof(CharacterSpawnRequest)); }
/// <summary> /// Search Searches for the entities as specified by the given query. /// </summary> /// <exception cref="Wallee.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="spaceId"></param> /// <param name="query">The query restricts the tokens which are returned by the search.</param> /// <returns>List<Token></returns> public List <Token> Search(long?spaceId, EntityQuery query) { ApiResponse <List <Token> > localVarResponse = SearchWithHttpInfo(spaceId, query); return(localVarResponse.Data); }
protected override void OnCreate() { commandBufferSystem = World.GetOrCreateSystem <BeginInitializationEntityCommandBufferSystem>(); query = GetEntityQuery(new ComponentType[] { typeof(TerrainSpawner) }); }
/// <summary> /// Search Searches for the entities as specified by the given query. /// </summary> /// <exception cref="Wallee.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="spaceId"></param> /// <param name="query">The query restricts the tokens which are returned by the search.</param> /// <returns>ApiResponse of List<Token></returns> public ApiResponse <List <Token> > SearchWithHttpInfo(long?spaceId, EntityQuery query) { // verify the required parameter 'spaceId' is set if (spaceId == null) { throw new ApiException(400, "Missing required parameter 'spaceId' when calling TokenService->Search"); } // verify the required parameter 'query' is set if (query == null) { throw new ApiException(400, "Missing required parameter 'query' when calling TokenService->Search"); } var localVarPath = "/token/search"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json;charset=utf-8" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json;charset=utf-8" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (spaceId != null) { localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "spaceId", spaceId)); // query parameter } if (query != null && query.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(query); // http body (model) parameter } else { localVarPostBody = query; // byte array } this.Configuration.ApiClient.ResetTimeout(); // make the HTTP request IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("Search", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <List <Token> >(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (List <Token>) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(List <Token>)))); }
protected override void OnCreate() { m_DataQuery = GetEntityQuery(typeof(ThrowingArmsSharedDataComponent)); }
protected override void OnCreateManager() { _query = Entities.WithAll <Health>().ToEntityQuery(); }
protected override void OnCreate() { base.OnCreate(); FocusablesQuery = GetEntityQuery(ComponentType.ReadOnly <CameraFocus>(), ComponentType.ReadOnly <Translation>()); }
protected override void OnCreate() { GravityQuery = GetEntityQuery(typeof(PhysicsStep)); inputDefinitionsClass = new InputDefinitionsClass(); groupIndexSystem = World.GetOrCreateSystem <GroupIndexSystem>(); }
/// <summary> /// Search Searches for the entities as specified by the given query. /// </summary> /// <exception cref="Wallee.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="spaceId"></param> /// <param name="query">The query restricts the external transfer bank transactions which are returned by the search.</param> /// <returns>List<ExternalTransferBankTransaction></returns> public List <ExternalTransferBankTransaction> Search(long?spaceId, EntityQuery query) { ApiResponse <List <ExternalTransferBankTransaction> > localVarResponse = SearchWithHttpInfo(spaceId, query); return(localVarResponse.Data); }
protected override void OnCreate() { m_endEcbSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>(); m_bedGroup = GetEntityQuery(ComponentType.ReadOnly <Bed>(), ComponentType.ReadOnly <Translation>()); }
public BlackboardDataQuery([NotNull] ComponentTypeSet set, Func <IEnumerable <ComponentType>, EntityQuery> createEntityQuery) { Set = set; Query = createEntityQuery(Set); }
protected override void OnCreate() { TimeQuery = GetEntityQuery(ComponentType.ReadOnly <GlobalGameTime>()); }
public static QueryResponse UpsertUrlAsAreaSubscription(EntityManager entMan, RecordManager recMan, Guid areaId, string url, string label, int weight, string iconName) { #region << Init >> var result = new QueryResponse(); result.Success = false; result.Message = "unknown error"; var areaList = new List <EntityRecord>(); var selectedArea = new EntityRecord(); var areaSubscriptionsText = ""; var selectedEntity = new Entity(); var selectedDetailsView = new RecordView(); var selectedCreateView = new RecordView(); var selectedList = new RecordList(); //Get areas EntityQuery query = new EntityQuery("area"); QueryResponse response = recMan.Find(query); if (!response.Success || !response.Object.Data.Any()) { result.Success = false; result.Message = response.Message; return(result); } areaList = response.Object.Data; selectedArea = null; foreach (var area in areaList) { if ((Guid)area["id"] == areaId) { selectedArea = area; } } if (selectedArea == null) { result.Success = false; result.Message = "There is no area with id " + areaId; return(result); } #endregion areaSubscriptionsText = (string)selectedArea["attachments"]; var areaSubscriptionsJsonObject = new JArray(); if (!String.IsNullOrWhiteSpace(areaSubscriptionsText)) { areaSubscriptionsJsonObject = JArray.Parse(areaSubscriptionsText); } var subscriptionToBeAdded = new JObject(); //Check if there is already a subscription for this entity bool subscriptionFound = false; foreach (var areaSubscription in areaSubscriptionsJsonObject) { //Yes - updated the view and list with the supplied if ((string)areaSubscription["url"] == url) { subscriptionFound = true; subscriptionToBeAdded["label"] = label; subscriptionToBeAdded["iconName"] = iconName; subscriptionToBeAdded["weight"] = weight; } } //No - create new subscription and Add it to the list if (!subscriptionFound) { subscriptionToBeAdded["name"] = null; subscriptionToBeAdded["label"] = label; subscriptionToBeAdded["labelPlural"] = null; subscriptionToBeAdded["iconName"] = iconName; subscriptionToBeAdded["weight"] = weight; subscriptionToBeAdded["url"] = url; //Add details view subscriptionToBeAdded["view"] = null; //Add create view subscriptionToBeAdded["create"] = null; //Add list subscriptionToBeAdded["list"] = null; areaSubscriptionsJsonObject.Add(subscriptionToBeAdded); } //Save area selectedArea["attachments"] = JsonConvert.SerializeObject(areaSubscriptionsJsonObject); QueryResponse updateAreaResponse = recMan.UpdateRecord("area", selectedArea); if (!updateAreaResponse.Success) { result.Success = false; result.Message = "There is problem updating the area with id" + areaId; return(result); } result.Success = true; result.Message = "Subscription successfully upserted"; return(result); }
protected override void OnCreate() { m_HybridRenderedQuery = GetEntityQuery(HybridUtils.GetHybridRenderedQueryDesc()); m_IsFirstFrame = true; }
protected override void OnCreateManager() { base.OnCreateManager(); Group = GetEntityQuery(typeof(Grenade.Settings), typeof(Grenade.InternalState)); }
protected override void OnCreate() { m_LineGroup = GetEntityQuery(ComponentType.ReadWrite <LineRendererComponentData>()); m_LineRenderSystem = World.GetOrCreateSystem <LineRenderSystem>(); }