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

Fix logic in TPT sproc validation where the root type is abstract #28877

Merged
merged 1 commit into from
Aug 25, 2022
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
10 changes: 7 additions & 3 deletions src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ private static void ValidateSproc(IStoredProcedure sproc, string mappingStrategy

foreach (var property in baseType.GetDeclaredProperties())
{
if (property.IsPrimaryKey())
{
continue;
}

properties.Add(property.Name, property);
}

Expand All @@ -351,8 +356,6 @@ private static void ValidateSproc(IStoredProcedure sproc, string mappingStrategy
}
}

var originalValueProperties = new Dictionary<string, IProperty>(properties);

var storeGeneratedProperties = storeObjectIdentifier.StoreObjectType switch
{
StoreObjectType.InsertStoredProcedure
Expand Down Expand Up @@ -418,6 +421,7 @@ private static void ValidateSproc(IStoredProcedure sproc, string mappingStrategy
}
}

var originalValueProperties = new Dictionary<string, IProperty>(properties);
var parameterNames = new HashSet<string>();
foreach (var parameter in sproc.Parameters)
{
Expand Down Expand Up @@ -615,7 +619,7 @@ protected virtual void ValidateBoolsWithDefaults(

static bool IsNotNullAndFalse(object? value)
=> value != null
&& (!(value is bool asBool) || asBool);
&& (value is not bool asBool || asBool);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ public StoreStoredProcedureParameter(
/// </summary>
public virtual StoreStoredProcedure StoredProcedure
=> (StoreStoredProcedure)Table;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 virtual ParameterDirection Direction { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 virtual int Position { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public StoreStoredProcedureReturnValue(
/// </summary>
public virtual StoreStoredProcedure StoredProcedure
=> (StoreStoredProcedure)Table;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public virtual IStoreStoredProcedure StoreStoredProcedure

/// <inheritdoc />
public virtual StoreObjectIdentifier StoredProcedureIdentifier { get; }

/// <inheritdoc />
public virtual ITableMapping? TableMapping { get; }

Expand Down
22 changes: 11 additions & 11 deletions src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public virtual bool IsInModel
/// </summary>
public virtual void SetRemovedFromModel()
=> _builder = null;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand All @@ -94,7 +94,7 @@ public override bool IsReadOnly
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual StoredProcedure StoredProcedure { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand All @@ -110,7 +110,7 @@ public override bool IsReadOnly
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual string? PropertyName { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -172,7 +172,7 @@ public virtual string SetName(string name, ConfigurationSource configurationSour

return name;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand All @@ -181,7 +181,7 @@ public virtual string SetName(string name, ConfigurationSource configurationSour
/// </summary>
public virtual ConfigurationSource? GetNameConfigurationSource()
=> _nameConfigurationSource;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand All @@ -208,7 +208,7 @@ public virtual ParameterDirection SetDirection(ParameterDirection direction, Con
RelationalStrings.StoredProcedureParameterInvalidConfiguration(
nameof(Direction), Name, ((IReadOnlyStoredProcedure)StoredProcedure).GetStoreIdentifier()?.DisplayName()));
}

if (!IsValid(direction))
{
throw new InvalidOperationException(RelationalStrings.StoredProcedureParameterInvalidDirection(
Expand Down Expand Up @@ -276,28 +276,28 @@ IReadOnlyStoredProcedure IReadOnlyStoredProcedureParameter.StoredProcedure
[DebuggerStepThrough]
get => StoredProcedure;
}

/// <inheritdoc />
IMutableStoredProcedure IMutableStoredProcedureParameter.StoredProcedure
{
[DebuggerStepThrough]
get => StoredProcedure;
}

/// <inheritdoc />
IConventionStoredProcedure IConventionStoredProcedureParameter.StoredProcedure
{
[DebuggerStepThrough]
get => StoredProcedure;
}

/// <inheritdoc />
IStoredProcedure IStoredProcedureParameter.StoredProcedure
{
[DebuggerStepThrough]
get => StoredProcedure;
}

/// <inheritdoc />
IConventionStoredProcedureParameterBuilder IConventionStoredProcedureParameter.Builder
{
Expand All @@ -308,7 +308,7 @@ IConventionStoredProcedureParameterBuilder IConventionStoredProcedureParameter.B
/// <inheritdoc />
string IConventionStoredProcedureParameter.SetName(string name, bool fromDataAnnotation)
=> SetName(name, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);

/// <inheritdoc />
ParameterDirection IConventionStoredProcedureParameter.SetDirection(ParameterDirection direction, bool fromDataAnnotation)
=> SetDirection(direction, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public StoredProcedureParameterMapping(
: base(property, storeParameter, storedProcedureMapping)
{
Parameter = parameter;
}
}

/// <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 @@ -16,7 +16,7 @@ public class StoredProcedureResultColumn :
IRuntimeStoredProcedureResultColumn
{
private string _name = "RowsAffected";

private ConfigurationSource? _nameConfigurationSource;
private InternalStoredProcedureResultColumnBuilder? _builder;

Expand Down Expand Up @@ -66,7 +66,7 @@ public virtual bool IsInModel
/// </summary>
public virtual void SetRemovedFromModel()
=> _builder = null;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand All @@ -83,7 +83,7 @@ public override bool IsReadOnly
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual StoredProcedure StoredProcedure { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand All @@ -99,7 +99,7 @@ public override bool IsReadOnly
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual string? PropertyName { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -136,21 +136,21 @@ public virtual string Name
_name = name;

_nameConfigurationSource = configurationSource.Max(_nameConfigurationSource);

return name;
}

if (configurationSource == ConfigurationSource.Explicit)
{
GetProperty().SetColumnName(name, ((IReadOnlyStoredProcedure)StoredProcedure).GetStoreIdentifier()!.Value);
return name;
}

return ((IConventionProperty)GetProperty()).SetColumnName(
name, ((IReadOnlyStoredProcedure)StoredProcedure).GetStoreIdentifier()!.Value,
fromDataAnnotation: configurationSource == ConfigurationSource.DataAnnotation);
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -195,28 +195,28 @@ IReadOnlyStoredProcedure IReadOnlyStoredProcedureResultColumn.StoredProcedure
[DebuggerStepThrough]
get => StoredProcedure;
}

/// <inheritdoc />
IMutableStoredProcedure IMutableStoredProcedureResultColumn.StoredProcedure
{
[DebuggerStepThrough]
get => StoredProcedure;
}

/// <inheritdoc />
IConventionStoredProcedure IConventionStoredProcedureResultColumn.StoredProcedure
{
[DebuggerStepThrough]
get => StoredProcedure;
}

/// <inheritdoc />
IStoredProcedure IStoredProcedureResultColumn.StoredProcedure
{
[DebuggerStepThrough]
get => StoredProcedure;
}

/// <inheritdoc />
IConventionStoredProcedureResultColumnBuilder IConventionStoredProcedureResultColumn.Builder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public StoredProcedureResultColumnMapping(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual IStoredProcedureResultColumn ResultColumn { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
20 changes: 10 additions & 10 deletions src/EFCore.Relational/Metadata/RuntimeStoredProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ IEntityType IStoredProcedure.EntityType
[DebuggerStepThrough]
get => _name;
}

/// <inheritdoc />
string IStoredProcedure.Name
{
Expand Down Expand Up @@ -160,7 +160,7 @@ IReadOnlyList<IReadOnlyStoredProcedureParameter> IReadOnlyStoredProcedure.Parame
[DebuggerStepThrough]
get => _parameters;
}

/// <inheritdoc />
IReadOnlyList<IStoredProcedureParameter> IStoredProcedure.Parameters
{
Expand All @@ -172,12 +172,12 @@ IReadOnlyList<IStoredProcedureParameter> IStoredProcedure.Parameters
IReadOnlyStoredProcedureParameter? IReadOnlyStoredProcedure.FindParameter(string propertyName)
=> _parameters.FirstOrDefault((IReadOnlyStoredProcedureParameter p)
=> p.ForOriginalValue == false && p.PropertyName == propertyName);

/// <inheritdoc />
[DebuggerStepThrough]
IStoredProcedureParameter? IStoredProcedure.FindParameter(string propertyName)
=> (IStoredProcedureParameter?)((IReadOnlyStoredProcedure)this).FindParameter(propertyName);

/// <inheritdoc />
IReadOnlyStoredProcedureParameter? IReadOnlyStoredProcedure.FindOriginalValueParameter(string propertyName)
=> _parameters.FirstOrDefault((IReadOnlyStoredProcedureParameter p)
Expand All @@ -186,12 +186,12 @@ IReadOnlyList<IStoredProcedureParameter> IStoredProcedure.Parameters
/// <inheritdoc />
IStoredProcedureParameter? IStoredProcedure.FindOriginalValueParameter(string propertyName)
=> (IStoredProcedureParameter?)((IReadOnlyStoredProcedure)this).FindOriginalValueParameter(propertyName);

/// <inheritdoc />
IReadOnlyStoredProcedureParameter? IReadOnlyStoredProcedure.FindRowsAffectedParameter()
=> _parameters.FirstOrDefault((IStoredProcedureParameter p)
=> p.ForRowsAffected);

/// <inheritdoc />
IStoredProcedureParameter? IStoredProcedure.FindRowsAffectedParameter()
=> (IStoredProcedureParameter?)((IReadOnlyStoredProcedure)this).FindRowsAffectedParameter();
Expand All @@ -202,7 +202,7 @@ IReadOnlyList<IReadOnlyStoredProcedureResultColumn> IReadOnlyStoredProcedure.Res
[DebuggerStepThrough]
get => _resultColumns;
}

/// <inheritdoc />
IReadOnlyList<IStoredProcedureResultColumn> IStoredProcedure.ResultColumns
{
Expand All @@ -214,7 +214,7 @@ IReadOnlyList<IStoredProcedureResultColumn> IStoredProcedure.ResultColumns
IReadOnlyStoredProcedureResultColumn? IReadOnlyStoredProcedure.FindResultColumn(string propertyName)
=> _resultColumns.FirstOrDefault((IReadOnlyStoredProcedureResultColumn c)
=> c.PropertyName == propertyName);

/// <inheritdoc />
IStoredProcedureResultColumn? IStoredProcedure.FindResultColumn(string propertyName)
=> (IStoredProcedureResultColumn?)((IReadOnlyStoredProcedure)this).FindResultColumn(propertyName);
Expand All @@ -223,7 +223,7 @@ IReadOnlyList<IStoredProcedureResultColumn> IStoredProcedure.ResultColumns
IReadOnlyStoredProcedureResultColumn? IReadOnlyStoredProcedure.FindRowsAffectedResultColumn()
=> _resultColumns.FirstOrDefault((IReadOnlyStoredProcedureResultColumn c)
=> c.ForRowsAffected);

/// <inheritdoc />
IStoredProcedureResultColumn? IStoredProcedure.FindRowsAffectedResultColumn()
=> (IStoredProcedureResultColumn?)((IReadOnlyStoredProcedure)this).FindRowsAffectedResultColumn();
Expand All @@ -234,7 +234,7 @@ IStoreStoredProcedure IStoredProcedure.StoreStoredProcedure
[DebuggerStepThrough]
get => _storeStoredProcedure!;
}

/// <inheritdoc />
IStoreStoredProcedure IRuntimeStoredProcedure.StoreStoredProcedure
{
Expand Down
Loading