private IEnumerable<CreateProcedureOperation> BuildCreateProcedureOperations( StorageAssociationSetModificationFunctionMapping modificationFunctionMapping, ModificationCommandTreeGenerator modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator) { DebugCheck.NotNull(modificationFunctionMapping); var insertCommandTrees = new DbInsertCommandTree[0]; var deleteCommandTrees = new DbDeleteCommandTree[0]; if (modificationCommandTreeGenerator != null) { var dynamicToFunctionModificationCommandConverter = new DynamicToFunctionModificationCommandConverter( modificationFunctionMapping, _target.StorageEntityContainerMapping); insertCommandTrees = dynamicToFunctionModificationCommandConverter .Convert( modificationCommandTreeGenerator .GenerateAssociationInsert(modificationFunctionMapping.AssociationSet.ElementType.Identity)) .ToArray(); deleteCommandTrees = dynamicToFunctionModificationCommandConverter .Convert( modificationCommandTreeGenerator .GenerateAssociationDelete(modificationFunctionMapping.AssociationSet.ElementType.Identity)) .ToArray(); } string insertBodySql = null, deleteBodySql = null; if (migrationSqlGenerator != null) { var providerManifestToken = _target.ProviderInfo.ProviderManifestToken; insertBodySql = migrationSqlGenerator .GenerateProcedureBody(insertCommandTrees, null, providerManifestToken); deleteBodySql = migrationSqlGenerator.GenerateProcedureBody( deleteCommandTrees, modificationFunctionMapping.DeleteFunctionMapping.RowsAffectedParameterName, providerManifestToken); } yield return BuildCreateProcedureOperation( modificationFunctionMapping.InsertFunctionMapping.Function, insertBodySql); yield return BuildCreateProcedureOperation( modificationFunctionMapping.DeleteFunctionMapping.Function, deleteBodySql); }
private void WriteModificationFunctionMapping(StorageAssociationSetModificationFunctionMapping modificationFunctionMapping) { DebugCheck.NotNull(modificationFunctionMapping); _xmlWriter.WriteStartElement(StorageMslConstructs.ModificationFunctionMappingElement); WriteFunctionMapping( StorageMslConstructs.InsertFunctionElement, modificationFunctionMapping.InsertFunctionMapping, associationSetMapping: true); WriteFunctionMapping( StorageMslConstructs.DeleteFunctionElement, modificationFunctionMapping.DeleteFunctionMapping, associationSetMapping: true); _xmlWriter.WriteEndElement(); }
public void Configure(StorageAssociationSetModificationFunctionMapping modificationFunctionMapping) { DebugCheck.NotNull(modificationFunctionMapping); if (_insertModificationFunctionConfiguration != null) { _insertModificationFunctionConfiguration .Configure(modificationFunctionMapping.InsertFunctionMapping); } if (_deleteModificationFunctionConfiguration != null) { _deleteModificationFunctionConfiguration .Configure(modificationFunctionMapping.DeleteFunctionMapping); } }