public virtual IStorageProviderCommand <IEnumerable <ObjectLookupResult <object> >, IRdbmsProviderCommandExecutionContext> CreateForMultiTimestampLookup( IEnumerable <ObjectID> objectIDs) { ArgumentUtility.CheckNotNull("objectIDs", objectIDs); var dbCommandBuildersAndReaders = from id in objectIDs let tableDefinition = _tableDefinitionFinder.GetTableDefinition(id) group id by tableDefinition into idsByTable let selectedColumns = idsByTable.Key.ObjectIDProperty.GetColumns().Concat(idsByTable.Key.TimestampProperty.GetColumns()).ToArray() let timestampReader = _objectReaderFactory.CreateTimestampReader(idsByTable.Key, selectedColumns) let dbCommandBuilder = CreateIDLookupDbCommandBuilder(idsByTable.Key, selectedColumns, idsByTable) select Tuple.Create(dbCommandBuilder, timestampReader); var loadCommand = new MultiObjectLoadCommand <Tuple <ObjectID, object> > (dbCommandBuildersAndReaders); return(DelegateBasedCommand.Create( loadCommand, lookupResults => lookupResults.Select( result => { Assertion.IsNotNull( result.Item1, "Because we included IDColumn into the projection and used it for the lookup, every row in the result set certainly has an ID."); return new ObjectLookupResult <object> (result.Item1, result.Item2); }))); }
protected virtual IStorageProviderCommand <IEnumerable <DataContainer>, IRdbmsProviderCommandExecutionContext> CreateForIndirectRelationLookup( UnionViewDefinition unionViewDefinition, RelationEndPointDefinition foreignKeyEndPoint, ObjectID foreignKeyValue, SortExpressionDefinition sortExpression) { var selectedColumns = unionViewDefinition.ObjectIDProperty.GetColumns(); var dbCommandBuilder = _dbCommandBuilderFactory.CreateForSelect( unionViewDefinition, selectedColumns, GetComparedColumns(foreignKeyEndPoint, foreignKeyValue), GetOrderedColumns(sortExpression)); var objectIDReader = _objectReaderFactory.CreateObjectIDReader(unionViewDefinition, selectedColumns); var objectIDLoadCommand = new MultiObjectIDLoadCommand(new[] { dbCommandBuilder }, objectIDReader); var indirectDataContainerLoadCommand = new IndirectDataContainerLoadCommand(objectIDLoadCommand, _storageProviderCommandFactory); return(DelegateBasedCommand.Create( indirectDataContainerLoadCommand, lookupResults => lookupResults.Select( result => { Assertion.IsNotNull( result.LocatedObject, "Because ID lookup and DataContainer lookup are executed within the same database transaction, the DataContainer can never be null."); return result.LocatedObject; }))); }
public void Create() { var innerCommandStub = MockRepository.GenerateStub <IStorageProviderCommand <string, object> >(); Func <string, int> operation = s => s.Length; var instance = DelegateBasedCommand.Create(innerCommandStub, operation); Assert.That(instance, Is.TypeOf(typeof(DelegateBasedCommand <string, int, object>))); Assert.That(instance.Command, Is.SameAs(innerCommandStub)); Assert.That(instance.Operation, Is.SameAs(operation)); }