public IStorageProviderCommand <IEnumerable <DataContainer>, IRdbmsProviderCommandExecutionContext> CreateForRelationLookup(
            RelationEndPointDefinition foreignKeyEndPoint, ObjectID foreignKeyValue, SortExpressionDefinition sortExpressionDefinition)
        {
            ArgumentUtility.CheckNotNull("foreignKeyEndPoint", foreignKeyEndPoint);
            ArgumentUtility.CheckNotNull("foreignKeyValue", foreignKeyValue);

            return(_relationLookupCommandFactory.CreateForRelationLookup(foreignKeyEndPoint, foreignKeyValue, sortExpressionDefinition));
        }
        public void CreateForRelationLookup_TableDefinition_NoSortExpression()
        {
            var classDefinition            = ClassDefinitionObjectMother.CreateClassDefinitionWithTable(classType: typeof(Order), storageProviderDefinition: TestDomainStorageProviderDefinition);
            var relationEndPointDefinition = CreateForeignKeyEndPointDefinition(classDefinition);
            var oppositeTable = (TableDefinition)relationEndPointDefinition.ClassDefinition.StorageEntityDefinition;

            _foreignKeyStoragePropertyDefinitionStrictMock.Expect(mock => mock.SplitValueForComparison(_foreignKeyValue)).Return(_fakeComparedColumns);
            _foreignKeyStoragePropertyDefinitionStrictMock.Replay();

            var expectedSelectedColumns = _tableDefinition.GetAllColumns();

            _dbCommandBuilderFactoryStrictMock
            .Expect(
                stub => stub.CreateForSelect(
                    Arg.Is((TableDefinition)classDefinition.StorageEntityDefinition),
                    Arg <IEnumerable <ColumnDefinition> > .List.Equal(expectedSelectedColumns),
                    Arg.Is(_fakeComparedColumns),
                    Arg <IEnumerable <OrderedColumn> > .List.Equal(new OrderedColumn[0])))
            .Return(_dbCommandBuilderStub);
            _dbCommandBuilderFactoryStrictMock.Replay();

            _objectReaderFactoryStrictMock
            .Expect(
                mock => mock.CreateDataContainerReader(
                    Arg.Is((IRdbmsStorageEntityDefinition)oppositeTable),
                    Arg <IEnumerable <ColumnDefinition> > .List.Equal(expectedSelectedColumns)))
            .Return(_dataContainerReaderStub);
            _objectReaderFactoryStrictMock.Replay();

            var result = _factory.CreateForRelationLookup(relationEndPointDefinition, _foreignKeyValue, null);

            _objectReaderFactoryStrictMock.VerifyAllExpectations();
            _foreignKeyStoragePropertyDefinitionStrictMock.VerifyAllExpectations();
            _dbCommandBuilderFactoryStrictMock.VerifyAllExpectations();

            Assert.That(result, Is.TypeOf(typeof(MultiObjectLoadCommand <DataContainer>)));
            var dbCommandBuilderTuples = ((MultiObjectLoadCommand <DataContainer>)result).DbCommandBuildersAndReaders;

            Assert.That(dbCommandBuilderTuples.Length, Is.EqualTo(1));
            Assert.That(dbCommandBuilderTuples[0].Item1, Is.SameAs(_dbCommandBuilderStub));
            Assert.That(dbCommandBuilderTuples[0].Item2, Is.SameAs(_dataContainerReaderStub));
        }