netmash/infrastructure/NDB.Infrastructure.Database.../Extensions/Mappings.cs

50 lines
1.8 KiB
C#

using System.Linq;
using e = Netmash.Infrastructure.DatabaseMigration.Entities;
using m = Netmash.Infrastructure.DatabaseMigration.Models;
namespace Netmash.Infrastructure.DatabaseMigration.Extensions
{
internal static class Mappings
{
public static m.MigratedVersion ToModel(this e.MigratedVersion migratedVersion)
{
return new m.MigratedVersion()
{
Version = migratedVersion.Version,
Scripts = migratedVersion.Scripts.Select(z => z.Script).ToArray()
};
}
public static m.MigrationSignature ToModel(this e.MigrationSignature migrationSignature)
{
return new m.MigrationSignature()
{
MigrationDate = migrationSignature.MigrationDate,
MachineName = migrationSignature.MachineName,
LastVersion = migrationSignature.LastVersion,
MigratedVersions = migrationSignature.MigratedVersions.Select(z => z.ToModel()).ToArray()
};
}
public static e.MigratedVersion ToEntity(this m.MigratedVersion migratedVersion)
{
return new e.MigratedVersion()
{
Version = migratedVersion.Version,
Scripts = migratedVersion.Scripts.Select(z => new e.MigratedScript() { Script = z }).ToArray()
};
}
public static e.MigrationSignature ToEntity(this m.MigrationSignature migrationSignature)
{
return new e.MigrationSignature()
{
MigrationDate = migrationSignature.MigrationDate,
MachineName = migrationSignature.MachineName,
LastVersion = migrationSignature.LastVersion,
MigratedVersions = migrationSignature.MigratedVersions.Select(z => z.ToEntity()).ToArray()
};
}
}
}