Skip to content

Commit

Permalink
Updated following design meeting feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed Dec 18, 2020
1 parent 1ae81d3 commit 97f2d50
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void Dispose()
}

public void Reset()
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);
}

private sealed class AsyncEnumerator : IAsyncEnumerator<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public ValueTask DisposeAsync()
}

public void Reset()
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);

private bool ShapeResult()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Linq.Expressions;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -110,7 +111,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution));

default:
throw new NotSupportedException();
throw new NotSupportedException(CoreStrings.UnhandledExpressionNode(shapedQueryExpression.QueryExpression));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ public void Dispose()
}

public void Reset()
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public ValueTask DisposeAsync()
}

public void Reset()
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/EFCore.Relational/Migrations/Migration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations.Operations;

Expand Down Expand Up @@ -118,9 +119,7 @@ protected virtual void BuildTargetModel([NotNull] ModelBuilder modelBuilder)
/// </summary>
/// <param name="migrationBuilder"> The <see cref="MigrationBuilder" /> that will build the operations. </param>
protected virtual void Down([NotNull] MigrationBuilder migrationBuilder)
{
throw new NotImplementedException();
}
=> throw new NotSupportedException(RelationalStrings.MigrationDownMissing);

private List<MigrationOperation> BuildOperations(Action<MigrationBuilder> buildAction)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/EFCore.Relational/Properties/RelationalStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@
<data name="MethodOnNonTPHRootNotSupported" xml:space="preserve">
<value>Using '{methodName}' on DbSet of '{entityType}' is not supported since '{entityType}' is part of hierarchy and does not contain a discriminator property.</value>
</data>
<data name="MigrationDownMissing" xml:space="preserve">
<value>The 'Down' method for this migration has not been implemented. Both the 'Up' abd 'Down' methods must be implemented to support reverting migrations.</value>
</data>
<data name="MigrationNotFound" xml:space="preserve">
<value>The migration '{migrationName}' was not found.</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Relational/Query/EntityProjectionExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private readonly IDictionary<INavigation, EntityShaperExpression> _ownedNavigati
[Obsolete("Use the constructor which takes populated column expressions map.", error: true)]
public EntityProjectionExpression([NotNull] IEntityType entityType, [NotNull] TableExpressionBase innerTable, bool nullable)
{
throw new NotSupportedException();
throw new NotSupportedException("Obsolete: Use the constructor which takes populated column expressions map.");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void Dispose()
}

public void Reset()
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);
}

private sealed class AsyncEnumerator : IAsyncEnumerator<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void Dispose()
}

public void Reset()
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);
}

private sealed class AsyncEnumerator : IAsyncEnumerator<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void Dispose()
}

public void Reset()
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);
}

private sealed class AsyncEnumerator : IAsyncEnumerator<T>
Expand Down
3 changes: 1 addition & 2 deletions src/EFCore.Relational/Storage/IRelationalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ Task<RelationalDataReader> ExecuteReaderAsync(
DbCommand CreateDbCommand(
RelationalCommandParameterObject parameterObject,
Guid commandId,
DbCommandMethod commandMethod)
=> throw new NotSupportedException();
DbCommandMethod commandMethod);
}
}
12 changes: 2 additions & 10 deletions src/EFCore.Relational/Storage/IRelationalConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ public interface IRelationalConnection : IRelationalTransactionManager, IDisposa
/// <summary>
/// Gets or sets the connection string for the database.
/// </summary>
string ConnectionString
{
get => throw new NotSupportedException();
[param: CanBeNull] set => throw new NotSupportedException();
}
string ConnectionString { get; [param: CanBeNull] set; }

/// <summary>
/// <para>
Expand All @@ -47,11 +43,7 @@ string ConnectionString
/// Note that the connection must be disposed by application code since it was not created by Entity Framework.
/// </para>
/// </summary>
DbConnection DbConnection
{
get => throw new NotSupportedException();
[param: CanBeNull] set => throw new NotSupportedException();
}
DbConnection DbConnection { get; [param: CanBeNull] set; }

/// <summary>
/// The <see cref="DbContext" /> currently in use, or null if not known.
Expand Down
6 changes: 6 additions & 0 deletions src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/EFCore.SqlServer/Properties/SqlServerStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@
<data name="NonKeyValueGeneration" xml:space="preserve">
<value>The property '{property}' on entity type '{entityType}' is configured to use 'SequenceHiLo' value generator, which is only intended for keys. If this was intentional, configure an alternate key on the property, otherwise call 'ValueGeneratedNever' or configure store generation for this property.</value>
</data>
<data name="NoSavepointRelease" xml:space="preserve">
<value>SQL Server does not support releasing a savepoint.</value>
</data>
<data name="SequenceBadType" xml:space="preserve">
<value>SQL Server sequences cannot be used to generate values for the property '{property}' on entity type '{entityType}' because the property type is '{propertyType}'. Sequences can only be used with integer properties.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.SqlServer.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -124,6 +125,6 @@ public override string GenerateRollbackToSavepointStatement(string name)
/// <param name="name"> The name of the savepoint to be released. </param>
/// <returns> An SQL string to release the savepoint. </returns>
public override string GenerateReleaseSavepointStatement(string name)
=> throw new NotSupportedException("SQL Server does not support releasing a savepoint");
=> throw new NotSupportedException(SqlServerStrings.NoSavepointRelease);
}
}
12 changes: 12 additions & 0 deletions src/EFCore/Properties/CoreStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/EFCore/Properties/CoreStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@
<data name="EntityTypesNotInRelationship" xml:space="preserve">
<value>The provided entity types '{invalidDependentType}' and '{invalidPrincipalType}' are invalid. Specify '{dependentType}' and '{principalType}', or entity types in the same hierarchy.</value>
</data>
<data name="EnumerableResetNotSupported" xml:space="preserve">
<value>This enumerator cannot be reset.</value>
</data>
<data name="ErrorInvalidQueryable" xml:space="preserve">
<value>Cannot use multiple context instances within a single query execution. Ensure the query uses a single context instance.</value>
</data>
Expand Down Expand Up @@ -1288,6 +1291,9 @@
<data name="RuntimeParameterMissingParameter" xml:space="preserve">
<value>While registering a runtime parameter, the lambda expression must have only one parameter which must be same as 'QueryCompilationContext.QueryContextParameter' expression.</value>
</data>
<data name="SavepointsNotSupported" xml:space="preserve">
<value>Savepoints are not supported by the database provider in use.</value>
</data>
<data name="SeedDatumDefaultValue" xml:space="preserve">
<value>The seed entity for entity type '{entityType}' cannot be added because a default value was provided for the required property '{property}'. Please provide a value different from '{defaultValue}'.</value>
</data>
Expand Down
9 changes: 5 additions & 4 deletions src/EFCore/Storage/IDbContextTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Storage
Expand Down Expand Up @@ -58,7 +59,7 @@ public interface IDbContextTransaction : IDisposable, IAsyncDisposable
/// </summary>
/// <param name="name"> The name of the savepoint to be created. </param>
void CreateSavepoint([NotNull] string name)
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.SavepointsNotSupported);

/// <summary>
/// Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint
Expand All @@ -70,14 +71,14 @@ void CreateSavepoint([NotNull] string name)
/// <returns> A <see cref="Task" /> representing the asynchronous operation. </returns>
/// <exception cref="OperationCanceledException"> If the <see cref="CancellationToken"/> is canceled. </exception>
Task CreateSavepointAsync([NotNull] string name, CancellationToken cancellationToken = default)
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.SavepointsNotSupported);

/// <summary>
/// Rolls back all commands that were executed after the specified savepoint was established.
/// </summary>
/// <param name="name"> The name of the savepoint to roll back to. </param>
void RollbackToSavepoint([NotNull] string name)
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.SavepointsNotSupported);

/// <summary>
/// Rolls back all commands that were executed after the specified savepoint was established.
Expand All @@ -87,7 +88,7 @@ void RollbackToSavepoint([NotNull] string name)
/// <returns> A <see cref="Task" /> representing the asynchronous operation. </returns>
/// <exception cref="OperationCanceledException"> If the <see cref="CancellationToken"/> is canceled. </exception>
Task RollbackToSavepointAsync([NotNull] string name, CancellationToken cancellationToken = default)
=> throw new NotSupportedException();
=> throw new NotSupportedException(CoreStrings.SavepointsNotSupported);

/// <summary>
/// <para>
Expand Down
6 changes: 2 additions & 4 deletions test/EFCore.Relational.Tests/RelationalEventIdTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,9 @@ public string FindMigrationId(string nameOrId)

private class FakeRelationalConnection : IRelationalConnection
{
public string ConnectionString
=> throw new NotImplementedException();
public string ConnectionString { get; set; }

public DbConnection DbConnection
=> new FakeDbConnection();
public DbConnection DbConnection { get; set; } = new FakeDbConnection();

public DbContext Context
=> null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;

Expand Down Expand Up @@ -203,6 +206,9 @@ public async Task<RelationalDataReader> ExecuteReaderAsync(
return result;
}

public DbCommand CreateDbCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)
=> throw new NotImplementedException();

private int? PreExecution(IRelationalConnection connection)
{
int? errorNumber = null;
Expand Down
25 changes: 10 additions & 15 deletions test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal;
using Microsoft.EntityFrameworkCore.Storage;
Expand Down Expand Up @@ -265,38 +267,31 @@ public IReadOnlyDictionary<string, object> ParameterValues
=> throw new NotImplementedException();

public int ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
{
return 0;
}
=> 0;

public Task<int> ExecuteNonQueryAsync(
RelationalCommandParameterObject parameterObject,
CancellationToken cancellationToken = default)
=> Task.FromResult(0);

public RelationalDataReader ExecuteReader(RelationalCommandParameterObject parameterObject)
{
throw new NotImplementedException();
}
=> throw new NotImplementedException();

public Task<RelationalDataReader> ExecuteReaderAsync(
RelationalCommandParameterObject parameterObject,
CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
=> throw new NotImplementedException();

public DbCommand CreateDbCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)
=> throw new NotImplementedException();

public object ExecuteScalar(RelationalCommandParameterObject parameterObject)
{
throw new NotImplementedException();
}
=> throw new NotImplementedException();

public Task<object> ExecuteScalarAsync(
RelationalCommandParameterObject parameterObject,
CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
=> throw new NotImplementedException();
}
}
}
Loading

0 comments on commit 97f2d50

Please sign in to comment.