Skip to content

Commit

Permalink
Synced to latest EF release commit
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Apr 3, 2015
1 parent 5a911de commit 8d96f24
Show file tree
Hide file tree
Showing 8 changed files with 315 additions and 185 deletions.
2 changes: 1 addition & 1 deletion external/EntityFramework
34 changes: 29 additions & 5 deletions src/Npgsql.EntityFramework7/Metadata/NpgsqlSequenceBuilder.cs
Expand Up @@ -31,7 +31,8 @@ public virtual NpgsqlSequenceBuilder IncrementBy(int increment)
increment,
_sequence.MinValue,
_sequence.MaxValue,
_sequence.Type);
_sequence.Type,
_sequence.Cycle);

model.Npgsql().AddOrReplaceSequence(_sequence);

Expand All @@ -49,7 +50,8 @@ public virtual NpgsqlSequenceBuilder Start(long startValue)
_sequence.IncrementBy,
_sequence.MinValue,
_sequence.MaxValue,
_sequence.Type);
_sequence.Type,
_sequence.Cycle);

model.Npgsql().AddOrReplaceSequence(_sequence);

Expand All @@ -67,7 +69,8 @@ public virtual NpgsqlSequenceBuilder Type<T>()
_sequence.IncrementBy,
_sequence.MinValue,
_sequence.MaxValue,
typeof(T));
typeof(T),
_sequence.Cycle);

model.Npgsql().AddOrReplaceSequence(_sequence);

Expand All @@ -85,7 +88,8 @@ public virtual NpgsqlSequenceBuilder Max(long maximum)
_sequence.IncrementBy,
_sequence.MinValue,
maximum,
_sequence.Type);
_sequence.Type,
_sequence.Cycle);

model.Npgsql().AddOrReplaceSequence(_sequence);

Expand All @@ -103,7 +107,27 @@ public virtual NpgsqlSequenceBuilder Min(long minimum)
_sequence.IncrementBy,
minimum,
_sequence.MaxValue,
_sequence.Type);
_sequence.Type,
_sequence.Cycle);

model.Npgsql().AddOrReplaceSequence(_sequence);

return this;
}

public virtual NpgsqlSequenceBuilder Cycle(bool cycle = true)
{
var model = (Model)_sequence.Model;

_sequence = new Sequence(
_sequence.Name,
_sequence.Schema,
_sequence.StartValue,
_sequence.IncrementBy,
_sequence.MinValue,
_sequence.MaxValue,
_sequence.Type,
cycle);

model.Npgsql().AddOrReplaceSequence(_sequence);

Expand Down
@@ -1,26 +1,13 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
using JetBrains.Annotations;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Relational.Migrations.Operations;
using Microsoft.Data.Entity.Utilities;

namespace Npgsql.EntityFramework7.Migrations
{
public class CreateDatabaseOperation : MigrationOperation
{
public CreateDatabaseOperation(
[NotNull] string name,
[CanBeNull] IReadOnlyDictionary<string, string> annotations = null)
: base(annotations)
{
Check.NotEmpty(name, nameof(name));

Name = name;
}

public virtual string Name { get; }
public virtual string Name { get;[param: NotNull] set; }
}
}
15 changes: 1 addition & 14 deletions src/Npgsql.EntityFramework7/Migrations/DropDatabaseOperation.cs
@@ -1,26 +1,13 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
using JetBrains.Annotations;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Relational.Migrations.Operations;
using Microsoft.Data.Entity.Utilities;

namespace Npgsql.EntityFramework7.Migrations
{
public class DropDatabaseOperation : MigrationOperation
{
public DropDatabaseOperation(
[NotNull] string name,
[CanBeNull] IReadOnlyDictionary<string, string> annotations = null)
: base(annotations)
{
Check.NotEmpty(name, nameof(name));

Name = name;
}

public virtual string Name { get; }
public virtual string Name { get;[param: NotNull] set; }
}
}
18 changes: 10 additions & 8 deletions src/Npgsql.EntityFramework7/Migrations/NpgsqlHistoryRepository.cs
Expand Up @@ -129,28 +129,30 @@ public virtual MigrationOperation GetDeleteOperation(string migrationId)
{
Check.NotEmpty(migrationId, nameof(migrationId));

return new SqlOperation(
new StringBuilder()
return new SqlOperation
{
Sql = new StringBuilder()
.AppendLine("DELETE FROM [dbo].[__MigrationHistory]")
.Append("WHERE [MigrationId] = '").Append(_sql.EscapeLiteral(migrationId))
.Append("' AND [ContextKey] = '").Append(_sql.EscapeLiteral(_contextType.FullName))
.AppendLine("';")
.ToString(),
suppressTransaction: false);
.ToString()
};
}

public virtual MigrationOperation GetInsertOperation(IHistoryRow row)
{
Check.NotNull(row, nameof(row));

return new SqlOperation(
new StringBuilder()
return new SqlOperation
{
Sql = new StringBuilder()
.AppendLine("INSERT INTO [dbo].[__MigrationHistory] ([MigrationId], [ContextKey], [ProductVersion])")
.Append("VALUES ('").Append(_sql.EscapeLiteral(row.MigrationId)).Append("', '")
.Append(_sql.EscapeLiteral(_contextType.FullName)).Append("', '")
.Append(_sql.EscapeLiteral(row.ProductVersion)).AppendLine("');")
.ToString(),
suppressTransaction: false);
.ToString()
};
}

public virtual string BeginIfNotExists(string migrationId)
Expand Down

0 comments on commit 8d96f24

Please sign in to comment.