Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Review Changes #22038

Merged
1 commit merged into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ public static string SetDatabaseName([NotNull] this IConventionIndex index, [Can
/// <param name="index"> The index. </param>
/// <param name="name"> The value to set. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> The configured value. </returns>
[Obsolete("Use SetDatabaseName() instead.")]
public static string SetName([NotNull] this IConventionIndex index, [CanBeNull] string name, bool fromDataAnnotation = false)
public static void SetName([NotNull] this IConventionIndex index, [CanBeNull] string name, bool fromDataAnnotation = false)
=> SetDatabaseName(index, name, fromDataAnnotation);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,17 @@ public static PropertyBuilder HasComputedColumnSql([NotNull] this PropertyBuilde
return propertyBuilder;
}

/// <summary>
/// Configures the property to map to a computed column when targeting a relational database.
/// </summary>
/// <param name="propertyBuilder"> The builder for the property being configured. </param>
/// <param name="sql"> The SQL expression that computes values for the column. </param>
/// <returns> The same builder instance so that multiple calls can be chained. </returns>
public static PropertyBuilder HasComputedColumnSql(
[NotNull] this PropertyBuilder propertyBuilder,
[CanBeNull] string sql)
=> HasComputedColumnSql(propertyBuilder, sql, null);

/// <summary>
/// Configures the property to map to a computed column when targeting a relational database.
/// </summary>
Expand All @@ -411,7 +422,7 @@ public static PropertyBuilder HasComputedColumnSql([NotNull] this PropertyBuilde
public static PropertyBuilder HasComputedColumnSql(
[NotNull] this PropertyBuilder propertyBuilder,
[CanBeNull] string sql,
bool? stored = null)
bool? stored)
{
Check.NotNull(propertyBuilder, nameof(propertyBuilder));
Check.NullButNotEmpty(sql, nameof(sql));
Expand Down Expand Up @@ -443,6 +454,18 @@ public static PropertyBuilder<TProperty> HasComputedColumnSql<TProperty>(
[NotNull] this PropertyBuilder<TProperty> propertyBuilder)
=> (PropertyBuilder<TProperty>)HasComputedColumnSql((PropertyBuilder)propertyBuilder);

/// <summary>
/// Configures the property to map to a computed column when targeting a relational database.
/// </summary>
/// <typeparam name="TProperty"> The type of the property being configured. </typeparam>
/// <param name="propertyBuilder"> The builder for the property being configured. </param>
/// <param name="sql"> The SQL expression that computes values for the column. </param>
/// <returns> The same builder instance so that multiple calls can be chained. </returns>
public static PropertyBuilder<TProperty> HasComputedColumnSql<TProperty>(
[NotNull] this PropertyBuilder<TProperty> propertyBuilder,
[CanBeNull] string sql)
=> HasComputedColumnSql(propertyBuilder, sql, null);

/// <summary>
/// Configures the property to map to a computed column when targeting a relational database.
/// </summary>
Expand All @@ -458,7 +481,7 @@ public static PropertyBuilder<TProperty> HasComputedColumnSql<TProperty>(
public static PropertyBuilder<TProperty> HasComputedColumnSql<TProperty>(
[NotNull] this PropertyBuilder<TProperty> propertyBuilder,
[CanBeNull] string sql,
bool? stored = null)
bool? stored)
=> (PropertyBuilder<TProperty>)HasComputedColumnSql((PropertyBuilder)propertyBuilder, sql, stored);

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions src/EFCore.Relational/Migrations/Internal/Migrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,14 @@ public virtual string GenerateScript(
if (!transactionStarted && !command.TransactionSuppressed)
{
builder
.AppendLine(_sqlGenerationHelper.StartTransaction)
.AppendLine(_sqlGenerationHelper.StartTransactionStatement)
.Append(_sqlGenerationHelper.BatchTerminator);
transactionStarted = true;
}
if (transactionStarted && command.TransactionSuppressed)
{
builder
.AppendLine(_sqlGenerationHelper.Commit)
.AppendLine(_sqlGenerationHelper.CommitTransactionStatement)
.Append(_sqlGenerationHelper.BatchTerminator);
transactionStarted = false;
}
Expand All @@ -393,7 +393,7 @@ public virtual string GenerateScript(
if (!noTransactions && transactionStarted)
{
builder
.AppendLine(_sqlGenerationHelper.Commit)
.AppendLine(_sqlGenerationHelper.CommitTransactionStatement)
.Append(_sqlGenerationHelper.BatchTerminator);
transactionStarted = false;
}
Expand All @@ -410,14 +410,14 @@ public virtual string GenerateScript(
if (!transactionStarted && !command.TransactionSuppressed)
{
builder
.AppendLine(_sqlGenerationHelper.StartTransaction)
.AppendLine(_sqlGenerationHelper.StartTransactionStatement)
.Append(_sqlGenerationHelper.BatchTerminator);
transactionStarted = true;
}
if (transactionStarted && command.TransactionSuppressed)
{
builder
.AppendLine(_sqlGenerationHelper.Commit)
.AppendLine(_sqlGenerationHelper.CommitTransactionStatement)
.Append(_sqlGenerationHelper.BatchTerminator);
transactionStarted = false;
}
Expand All @@ -444,7 +444,7 @@ public virtual string GenerateScript(
if (!noTransactions && transactionStarted)
{
builder
.AppendLine(_sqlGenerationHelper.Commit)
.AppendLine(_sqlGenerationHelper.CommitTransactionStatement)
.Append(_sqlGenerationHelper.BatchTerminator);
transactionStarted = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Relational/Storage/ISqlGenerationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public interface ISqlGenerationHelper
/// <summary>
/// Gets the SQL for a START TRANSACTION statement.
/// </summary>
string StartTransaction { get; }
string StartTransactionStatement { get; }

/// <summary>
/// Gets the SQL for a COMMIT statement.
/// </summary>
string Commit { get; }
string CommitTransactionStatement { get; }

/// <summary>
/// The default single-line comment prefix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public RelationalSqlGenerationHelper([NotNull] RelationalSqlGenerationHelperDepe
public virtual string BatchTerminator => Environment.NewLine;

/// <inheritdoc />
public virtual string StartTransaction => "START TRANSACTION" + StatementTerminator;
public virtual string StartTransactionStatement => "START TRANSACTION" + StatementTerminator;

/// <inheritdoc />
public virtual string Commit => "COMMIT" + StatementTerminator;
public virtual string CommitTransactionStatement => "COMMIT" + StatementTerminator;

/// <summary>
/// The default single-line comment prefix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public SqlServerSqlGenerationHelper([NotNull] RelationalSqlGenerationHelperDepen
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override string StartTransaction => "BEGIN TRANSACTION" + StatementTerminator;
public override string StartTransactionStatement => "BEGIN TRANSACTION" + StatementTerminator;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public SqliteSqlGenerationHelper([NotNull] RelationalSqlGenerationHelperDependen
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override string StartTransaction
public override string StartTransactionStatement
=> "BEGIN TRANSACTION" + StatementTerminator;

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions src/EFCore/Extensions/ConventionEntityTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,8 @@ public static LambdaExpression SetQueryFilter(
/// <param name="entityType"> The entity type. </param>
/// <param name="definingQuery"> The LINQ query used as the default source. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> The configured entity type. </returns>
[Obsolete("Use InMemoryEntityTypeExtensions.SetInMemoryQuery")]
public static LambdaExpression SetDefiningQuery(
public static void SetDefiningQuery(
[NotNull] this IConventionEntityType entityType,
[CanBeNull] LambdaExpression definingQuery,
bool fromDataAnnotation = false)
Expand Down
5 changes: 2 additions & 3 deletions src/EFCore/Extensions/ConventionPropertyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ public static ValueComparer SetValueComparer(
/// <param name="property"> The property. </param>
/// <param name="comparer"> The comparer, or <see langword="null" /> to remove any previously set comparer. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> The configured value. </returns>
[Obsolete("Use SetValueComparer. Only a single value comparer is allowed for a given property.")]
public static ValueComparer SetKeyValueComparer(
public static void SetKeyValueComparer(
[NotNull] this IConventionProperty property,
[CanBeNull] ValueComparer comparer,
bool fromDataAnnotation = false)
Expand All @@ -383,7 +382,7 @@ public static ValueComparer SetKeyValueComparer(
/// <param name="comparer"> The comparer, or <see langword="null" /> to remove any previously set comparer. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
[Obsolete("Use SetValueComparer. Only a single value comparer is allowed for a given property.")]
public static ValueComparer SetStructuralValueComparer(
public static void SetStructuralValueComparer(
[NotNull] this IConventionProperty property,
[CanBeNull] ValueComparer comparer,
bool fromDataAnnotation = false)
Expand Down
4 changes: 1 addition & 3 deletions src/EFCore/Metadata/Internal/EntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3127,11 +3127,9 @@ public virtual string CheckQueryFilter([CanBeNull] LambdaExpression queryFilter)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[Obsolete]
public virtual LambdaExpression SetDefiningQuery([CanBeNull] LambdaExpression definingQuery, ConfigurationSource configurationSource)
public virtual void SetDefiningQuery([CanBeNull] LambdaExpression definingQuery, ConfigurationSource configurationSource)
{
this.SetOrRemoveAnnotation(CoreAnnotationNames.DefiningQuery, definingQuery, configurationSource);

return definingQuery;
}

/// <summary>
Expand Down
6 changes: 0 additions & 6 deletions src/EFCore/Query/QueryCompilationContextDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ public QueryCompilationContextDependencies(
/// </summary>
public Type ContextType => _currentContext.Context.GetType();

/// <summary>
/// The flag indicating if default query tracking behavior is tracking.
/// </summary>
[Obsolete("Use " + nameof(QueryTrackingBehavior) + " instead.")]
public bool IsTracking => _currentContext.Context.ChangeTracker.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll;

/// <summary>
/// The default query tracking behavior.
/// </summary>
Expand Down
3 changes: 0 additions & 3 deletions test/EFCore.Tests/ApiConsistencyTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,9 +1020,6 @@ protected ApiConsistencyFixtureBase()
typeof(ProviderConventionSetBuilderDependencies).GetProperty(nameof(ProviderConventionSetBuilderDependencies.ContextType)),
typeof(QueryCompilationContextDependencies).GetProperty(nameof(QueryCompilationContextDependencies.ContextType)),
typeof(QueryCompilationContextDependencies).GetProperty(nameof(QueryCompilationContextDependencies.QueryTrackingBehavior)),
#pragma warning disable CS0618 // Type or member is obsolete
typeof(QueryCompilationContextDependencies).GetProperty(nameof(QueryCompilationContextDependencies.IsTracking)),
#pragma warning restore CS0618 // Type or member is obsolete
typeof(QueryContextDependencies).GetProperty(nameof(QueryContextDependencies.StateManager)),
#pragma warning disable CS0618 // Type or member is obsolete
typeof(QueryContextDependencies).GetProperty(nameof(QueryContextDependencies.QueryProvider))
Expand Down