コード例 #1
0
        public void GenerateCode(HardcodedEntityInfo concept, IDataMigrationScriptBuilder codeBuilder)
        {
            codeBuilder.AddBeforeDataMigrationScript($@"
EXEC Rhetos.DataMigrationUse '{concept.Module.Name}', '{concept.Name}', 'ID', 'uniqueidentifier';{DataMigrationUseTag.Evaluate(concept)}
GO

DECLARE @entries TABLE (ID uniqueidentifier PRIMARY KEY);
{InsertValuesTag.Evaluate(concept)}

INSERT INTO _{concept.Module.Name}.{concept.Name} (ID)
SELECT newItem.ID
FROM @entries newItem
	LEFT JOIN _{concept.Module.Name}.{concept.Name} existingItem ON existingItem.ID = newItem.ID
WHERE
	existingItem.ID IS NULL;
{UpdateTag.Evaluate(concept)}

DECLARE @ColumnNames nvarchar(max);
SET @ColumnNames = 'ID'{DataMigrationApplyMultipleTag.Evaluate(concept)};
EXEC Rhetos.DataMigrationApplyMultiple '{concept.Module.Name}', '{concept.Name}', @ColumnNames;");

            codeBuilder.AddAfterDataMigrationScript(
                $@"EXEC Rhetos.DataMigrationUse '{concept.Module.Name}', '{concept.Name}', 'ID', 'uniqueidentifier';
GO

DECLARE @entries TABLE (ID uniqueidentifier PRIMARY KEY);
{InsertValuesTag.Evaluate(concept)}

DELETE FROM _{concept.Module.Name}.{concept.Name} WHERE ID NOT IN
(
    SELECT ID FROM @entries
);

EXEC Rhetos.DataMigrationApplyMultiple '{concept.Module.Name}', '{concept.Name}', 'ID';");
        }
コード例 #2
0
        public void GenerateCode(EntryValueInfo concept, IDataMigrationScriptBuilder codeBuilder)
        {
            var databaseColumnName = _conceptMetadata.GetColumnName(concept.Property);
            var databaseColumnType = _conceptMetadata.GetColumnType(concept.Property);

            codeBuilder.InsertCode($@",{Environment.NewLine}    {databaseColumnName} = CONVERT({databaseColumnType}, {SqlUtility.QuoteText(concept.Value)})",
                                   EntryDataMigrationScript.UpdatePropertyTag, concept.Entry);
        }
コード例 #3
0
        public void GenerateCode(EntryInfo concept, IDataMigrationScriptBuilder codeBuilder)
        {
            string insertSnippet = $@"
INSERT INTO @entries (ID) VALUES ('{concept.GetIdentifier()}');";

            codeBuilder.InsertCode(insertSnippet, HardcodedEntityDataMigrationScript.InsertValuesTag, concept.HardcodedEntity);

            codeBuilder.InsertCode($@"

UPDATE _{concept.HardcodedEntity.Module.Name}.{concept.HardcodedEntity.Name}
SET Name = '{concept.Name}'{UpdatePropertyTag.Evaluate(concept)}
WHERE ID = '{concept.GetIdentifier()}';",
                                   HardcodedEntityDataMigrationScript.UpdateTag, concept.HardcodedEntity);
        }
コード例 #4
0
        public void GenerateCode(PropertyInfo concept, IDataMigrationScriptBuilder codeBuilder)
        {
            if (concept.DataStructure is HardcodedEntityInfo)
            {
                var databaseColumnName = _conceptMetadata.GetColumnName(concept);
                var databaseColumnType = _conceptMetadata.GetColumnType(concept);

                codeBuilder.InsertCode(Environment.NewLine + $@"EXEC Rhetos.DataMigrationUse '{concept.DataStructure.Module.Name}', '{concept.DataStructure.Name}', '{databaseColumnName}', '{databaseColumnType}';",
                                       HardcodedEntityDataMigrationScript.DataMigrationUseTag, concept.DataStructure as HardcodedEntityInfo);

                codeBuilder.InsertCode($@" + ', {databaseColumnName}'",
                                       HardcodedEntityDataMigrationScript.DataMigrationApplyMultipleTag, concept.DataStructure as HardcodedEntityInfo);
            }
        }
コード例 #5
0
 public static void GenerateCode(this IConceptDataMigration dataMigrationScript, IConceptInfo conceptInfo, IDataMigrationScriptBuilder dataMigrationScriptBuilder)
 {
     foreach (var method in GetPluginMethods(dataMigrationScript, conceptInfo))
     {
         method.InvokeEx(dataMigrationScript, new object[] { conceptInfo, dataMigrationScriptBuilder });
     }
 }