public void ResolveIDPropertyViaForeignKey_WithFullObjectID_ResolvesToCompound() { var propertyDefinition = CreatePropertyDefinitionAndAssociateWithClass(_classDefinition, "Customer", "Customer"); var objectIDStorageProperty = ObjectIDStoragePropertyDefinitionObjectMother.Create( "CustomerID", "CustomerClassID", StorageTypeInformationObjectMother.CreateUniqueIdentifierStorageTypeInformation(), StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation()); var foreignKeyEndPointDefinition = new RelationEndPointDefinition(propertyDefinition, false); _rdbmsPersistenceModelProviderStub .Stub(stub => stub.GetStoragePropertyDefinition(foreignKeyEndPointDefinition.PropertyDefinition)) .Return(objectIDStorageProperty); var originatingEntity = CreateEntityDefinition(typeof(Order), "o"); var result = _storageSpecificExpressionResolver.ResolveIDPropertyViaForeignKey(originatingEntity, foreignKeyEndPointDefinition); var expected = Expression.New( MemberInfoFromExpressionUtility.GetConstructor(() => new ObjectID("classID", "value")), new[] { new NamedExpression("ClassID", originatingEntity.GetColumn(typeof(string), "CustomerClassID", false)), new NamedExpression("Value", Expression.Convert(originatingEntity.GetColumn(typeof(Guid), "CustomerID", false), typeof(object))) }, new[] { typeof(ObjectID).GetProperty("ClassID"), typeof(ObjectID).GetProperty("Value") }); SqlExpressionTreeComparer.CheckAreEqualTrees(expected, result); }
public override void SetUp() { base.SetUp(); _factory = new SqlTableScriptElementFactory(); var column1 = new ColumnDefinition("Column1", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation(false), false); var column2 = new ColumnDefinition("Column2", StorageTypeInformationObjectMother.CreateBitStorageTypeInformation(true), false); var property1 = new SimpleStoragePropertyDefinition(typeof(string), column1); var property2 = new SimpleStoragePropertyDefinition(typeof(bool), column2); var idColumn = new ColumnDefinition("ID", StorageTypeInformationObjectMother.CreateUniqueIdentifierStorageTypeInformation(false), true); var classIDColumn = new ColumnDefinition("ClassID", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation(true), false); var objectIDProperty = new ObjectIDStoragePropertyDefinition( new SimpleStoragePropertyDefinition(typeof(object), idColumn), new SimpleStoragePropertyDefinition(typeof(string), classIDColumn)); var timestampColumn = new ColumnDefinition("Timestamp", StorageTypeInformationObjectMother.CreateDateTimeStorageTypeInformation(true), false); var timestampProperty = new SimpleStoragePropertyDefinition(typeof(object), timestampColumn); _tableDefinitionWithoutPrimaryKeyConstraint = TableDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition("SchemaName", "EntityName"), null, objectIDProperty, timestampProperty, property1); _tableDefinitionWithClusteredPrimaryKeyConstraint = TableDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition("SchemaName", "EntityName"), null, objectIDProperty, timestampProperty, new[] { property1, property2 }, new ITableConstraintDefinition[] { new PrimaryKeyConstraintDefinition("PKName", true, new[] { column1 }) }); _tableDefinitionWithNonClusteredPrimaryKeyConstraint = TableDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition(null, "EntityName"), null, objectIDProperty, timestampProperty, new[] { property1, property2 }, new ITableConstraintDefinition[] { new PrimaryKeyConstraintDefinition("PKName", false, new[] { column1, column2 }) }); }
public void SetUp() { _columnDefinition = ColumnDefinitionObjectMother.CreateColumn("Column", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation()); _objectValue1 = "<Test1"; _objectValue2 = 689; _objectValue3 = true; _specification = new SqlXmlSetComparedColumnSpecification(_columnDefinition, new[] { _objectValue1, _objectValue2, _objectValue3 }); _statement = new StringBuilder(); _parametersCollectionMock = MockRepository.GenerateStrictMock <IDataParameterCollection> (); _commandStub = MockRepository.GenerateStub <IDbCommand> (); _commandStub.Stub(stub => stub.Parameters).Return(_parametersCollectionMock); _parameterStub = MockRepository.GenerateStub <IDbDataParameter>(); _commandStub.Stub(stub => stub.CreateParameter()).Return(_parameterStub); _sqlDialectStub = MockRepository.GenerateStub <ISqlDialect> (); _sqlDialectStub.Stub(stub => stub.StatementDelimiter).Return("delimiter"); }
public override void SetUp() { base.SetUp(); _factory = new SqlEmptyViewScriptElementFactory(); var property1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation()); var property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation()); _emptyViewDefinitionWithCustomSchema = EmptyViewDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition("SchemaName", "EmptyView1"), ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty, SimpleStoragePropertyDefinitionObjectMother.TimestampProperty, new[] { property1 }); _emptyViewDefinitionWithDefaultSchema = EmptyViewDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition(null, "EmptyView2"), ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty, SimpleStoragePropertyDefinitionObjectMother.TimestampProperty, new[] { property1, property2 }); }