public void TestFilter() { var spec = SpecificationFactory <Foo> .Contains(foo => foo.Id, Enumerable.Range(0, MsSqlBatchLimitation).ToArray()); var batchSpec = spec.WrappedSpecs.Single(); var items = new[] { new Foo { Id = -1 }, new Foo { Id = 0 }, new Foo { Id = MsSqlBatchLimitation - 1 }, new Foo { Id = MsSqlBatchLimitation }, }; var filteredItems = items.AsQueryable().Where(batchSpec); Assert.AreEqual(0, filteredItems.Count(x => x.Id == -1)); Assert.AreEqual(1, filteredItems.Count(x => x.Id == 0)); Assert.AreEqual(1, filteredItems.Count(x => x.Id == MsSqlBatchLimitation - 1)); Assert.AreEqual(0, filteredItems.Count(x => x.Id == MsSqlBatchLimitation)); }
public void TestBatches(int idCount, int batchCount) { var spec = SpecificationFactory <Foo> .Contains(foo => foo.Id, Enumerable.Repeat(0, idCount).ToArray()); var batchSpecs = spec.WrappedSpecs; Assert.AreEqual(batchCount, batchSpecs.Count); }
private static FindSpecification <EntityName> GetFindSpecification(IReadOnlyCollection <ICommand> commands, Type type, int typeId) { var ids = commands.Cast <SyncDataObjectCommand>() .Where(c => c.DataObjectType == type) .Distinct() .Select(c => new { Id = c.DataObjectId, EntityType = typeId }).ToList(); return(SpecificationFactory <EntityName> .Contains(x => new { x.Id, x.EntityType }, ids)); }
public FindSpecification <Price> GetFindSpecification(IReadOnlyCollection <ICommand> commands) { var ids = commands.Cast <SyncDataObjectCommand>().Select(c => c.DataObjectId).ToList(); return(SpecificationFactory <Price> .Contains(x => x.Id, ids)); }
public FindSpecification <SalesModelCategoryRestriction> GetFindSpecification(IReadOnlyCollection <ICommand> commands) { var ids = commands.Cast <SyncDataObjectCommand>().Select(c => c.DataObjectId).ToList(); return(SpecificationFactory <SalesModelCategoryRestriction> .Contains(x => x.ProjectId, ids)); }
public FindSpecification <OrderPositionCostPerClick> GetFindSpecification(IReadOnlyCollection <ICommand> commands) { var ids = commands.Cast <SyncDataObjectCommand>().Select(c => c.DataObjectId).ToList(); return(SpecificationFactory <OrderPositionCostPerClick> .Contains(x => x.OrderPositionId, ids)); }
public FindSpecification<CategoryOrganizationUnit> GetFindSpecification(IReadOnlyCollection<ICommand> commands) { var ids = commands.Cast<SyncDataObjectCommand>().Select(c => c.DataObjectId).ToList(); return SpecificationFactory<CategoryOrganizationUnit>.Contains(x => x.Id, ids); }