Skip to content
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
8 changes: 0 additions & 8 deletions src/EFCore.Design/Properties/DesignStrings.Designer.cs

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

3 changes: 0 additions & 3 deletions src/EFCore.Design/Properties/DesignStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@
<data name="CompiledModelCustomCacheKeyFactory" xml:space="preserve">
<value>The context is configured to use a custom model cache key factory '{factoryType}', this usually indicates that the produced model can change between context instances. To preserve this behavior manually modify the generated compiled model source code.</value>
</data>
<data name="CompiledModelDefiningQuery" xml:space="preserve">
<value>The entity type '{entityType}' has a defining query configured. Compiled model can't be generated, because defining queries are not supported.</value>
</data>
<data name="CompiledModelGenerated" xml:space="preserve">
<value>Successfully generated a compiled model, it will be discovered automatically, but you can also call '{optionsCall}'. Run this command again when the model is modified.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,6 @@ private void Create(IEntityType entityType, CSharpRuntimeAnnotationCodeGenerator
throw new InvalidOperationException(DesignStrings.CompiledModelQueryFilter(entityType.ShortName()));
}

#pragma warning disable CS0618 // Type or member is obsolete
if (entityType.GetDefiningQuery() != null)
{
// TODO: Move to InMemoryCSharpRuntimeAnnotationCodeGenerator, see #21624
throw new InvalidOperationException(DesignStrings.CompiledModelDefiningQuery(entityType.ShortName()));
}
#pragma warning restore CS0618 // Type or member is obsolete

AddNamespace(entityType.ClrType, parameters.Namespaces);

var mainBuilder = parameters.MainBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.InMemory.Internal;

namespace Microsoft.EntityFrameworkCore.InMemory.Design.Internal;

Expand All @@ -25,4 +26,20 @@ public InMemoryCSharpRuntimeAnnotationCodeGenerator(
: base(dependencies)
{
}

/// <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 override void Generate(IEntityType entityType, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
{
if (entityType.GetInMemoryQuery() != null)
{
throw new InvalidOperationException(InMemoryStrings.CompiledModelDefiningQuery(entityType.DisplayName()));
}

base.Generate(entityType, parameters);
}
}
2 changes: 1 addition & 1 deletion src/EFCore.InMemory/EFCore.InMemory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<MinClientVersion>3.6</MinClientVersion>
<AssemblyName>Microsoft.EntityFrameworkCore.InMemory</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore.InMemory</RootNamespace>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>$(PackageTags);In-Memory</PackageTags>
<ImplicitUsings>true</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,5 @@ public static bool CanSetInMemoryQuery(
this IConventionEntityTypeBuilder entityTypeBuilder,
LambdaExpression? query,
bool fromDataAnnotation = false)
#pragma warning disable EF1001 // Internal EF Core API usage.
#pragma warning disable CS0612 // Type or member is obsolete
=> entityTypeBuilder.CanSetAnnotation(CoreAnnotationNames.DefiningQuery, query, fromDataAnnotation);
#pragma warning restore CS0612 // Type or member is obsolete
#pragma warning restore EF1001 // Internal EF Core API usage.
=> entityTypeBuilder.CanSetAnnotation(InMemoryAnnotationNames.DefiningQuery, query, fromDataAnnotation);
}
26 changes: 5 additions & 21 deletions src/EFCore.InMemory/Extensions/InMemoryEntityTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ public static class InMemoryEntityTypeExtensions
/// <param name="entityType">The entity type to get the in-memory query for.</param>
/// <returns>The LINQ query used as the default source.</returns>
public static LambdaExpression? GetInMemoryQuery(this IReadOnlyEntityType entityType)
#pragma warning disable EF1001 // Internal EF Core API usage.
#pragma warning disable CS0612 // Type or member is obsolete
=> (LambdaExpression?)entityType[CoreAnnotationNames.DefiningQuery];
#pragma warning restore CS0612 // Type or member is obsolete
#pragma warning restore EF1001 // Internal EF Core API usage.
=> (LambdaExpression?)entityType[InMemoryAnnotationNames.DefiningQuery];

/// <summary>
/// Sets the LINQ query used as the default source for queries of this type.
Expand All @@ -36,11 +32,7 @@ public static void SetInMemoryQuery(
this IMutableEntityType entityType,
LambdaExpression? inMemoryQuery)
=> entityType
#pragma warning disable EF1001 // Internal EF Core API usage.
#pragma warning disable CS0612 // Type or member is obsolete
.SetOrRemoveAnnotation(CoreAnnotationNames.DefiningQuery, inMemoryQuery);
#pragma warning restore CS0612 // Type or member is obsolete
#pragma warning restore EF1001 // Internal EF Core API usage.
.SetOrRemoveAnnotation(InMemoryAnnotationNames.DefiningQuery, inMemoryQuery);

/// <summary>
/// Sets the LINQ query used as the default source for queries of this type.
Expand All @@ -54,22 +46,14 @@ public static void SetInMemoryQuery(
LambdaExpression? inMemoryQuery,
bool fromDataAnnotation = false)
=> (LambdaExpression?)entityType
#pragma warning disable EF1001 // Internal EF Core API usage.
#pragma warning disable CS0612 // Type or member is obsolete
.SetOrRemoveAnnotation(CoreAnnotationNames.DefiningQuery, inMemoryQuery, fromDataAnnotation)
#pragma warning restore CS0612 // Type or member is obsolete
#pragma warning restore EF1001 // Internal EF Core API usage.
.SetOrRemoveAnnotation(InMemoryAnnotationNames.DefiningQuery, inMemoryQuery, fromDataAnnotation)
?.Value;

/// <summary>
/// Returns the configuration source for <see cref="GetInMemoryQuery" />.
/// </summary>
/// <param name="entityType">The entity type.</param>
/// <returns>The configuration source for <see cref="GetInMemoryQuery" />.</returns>
public static ConfigurationSource? GetDefiningQueryConfigurationSource(this IConventionEntityType entityType)
#pragma warning disable EF1001 // Internal EF Core API usage.
#pragma warning disable CS0612 // Type or member is obsolete
=> entityType.FindAnnotation(CoreAnnotationNames.DefiningQuery)?.GetConfigurationSource();
#pragma warning restore CS0612 // Type or member is obsolete
#pragma warning restore EF1001 // Internal EF Core API usage.
public static ConfigurationSource? GetInMemoryQueryConfigurationSource(this IConventionEntityType entityType)
=> entityType.FindAnnotation(InMemoryAnnotationNames.DefiningQuery)?.GetConfigurationSource();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.ComponentModel;
using Microsoft.EntityFrameworkCore.InMemory.Diagnostics.Internal;
using Microsoft.EntityFrameworkCore.InMemory.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.InMemory.Query.Internal;
using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal;
using Microsoft.EntityFrameworkCore.InMemory.ValueGeneration.Internal;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions;
namespace Microsoft.EntityFrameworkCore.Metadata.Conventions;

/// <summary>
/// A builder for building conventions for th in-memory provider.
Expand Down
29 changes: 29 additions & 0 deletions src/EFCore.InMemory/Metadata/Internal/CosmosAnnotationNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Metadata.Internal;

/// <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 static class InMemoryAnnotationNames
{
/// <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 const string Prefix = "InMemory:";

/// <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 const string DefiningQuery = Prefix + "DefiningQuery";
}
12 changes: 10 additions & 2 deletions src/EFCore.InMemory/Properties/InMemoryStrings.Designer.cs

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

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<#
Session = new System.Collections.Generic.Dictionary<string, object>();
Session["ResourceFile"] = "InMemoryStrings.resx";
Session["ResourceNamespace"] = "Microsoft.EntityFrameworkCore.InMemory.Properties";
Session["ResourceNamespace"] = "Microsoft.EntityFrameworkCore.Properties";
Session["LoggingDefinitionsClass"] = "Diagnostics.Internal.InMemoryLoggingDefinitions";
#>
<#@ include file="..\..\..\tools\Resources.tt" #>
3 changes: 3 additions & 0 deletions src/EFCore.InMemory/Properties/InMemoryStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CompiledModelDefiningQuery" xml:space="preserve">
<value>The entity type '{entityType}' has a defining query configured. Compiled model can't be generated, because defining queries are not supported.</value>
</data>
<data name="DefaultIfEmptyAppliedAfterProjection" xml:space="preserve">
<value>Cannot apply 'DefaultIfEmpty' after a client-evaluated projection. Consider applying 'DefaultIfEmpty' before last 'Select' or use 'AsEnumerable' before 'DefaultIfEmpty' to apply it on client-side.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public static class RelationalEntityTypeExtensions

return ((entityType as IConventionEntityType)?.GetViewNameConfigurationSource() == null)
&& (entityType as IConventionEntityType)?.GetFunctionNameConfigurationSource() == null
#pragma warning disable CS0618 // Type or member is obsolete
&& (entityType as IConventionEntityType)?.GetDefiningQueryConfigurationSource() == null
#pragma warning restore CS0618 // Type or member is obsolete
&& (entityType as IConventionEntityType)?.GetSqlQueryConfigurationSource() == null
? GetDefaultTableName(entityType)
: null;
Expand Down Expand Up @@ -267,9 +264,6 @@ public static void SetSchema(this IMutableEntityType entityType, string? value)
}

return ((entityType as IConventionEntityType)?.GetFunctionNameConfigurationSource() == null)
#pragma warning disable CS0618 // Type or member is obsolete
&& ((entityType as IConventionEntityType)?.GetDefiningQueryConfigurationSource() == null)
#pragma warning restore CS0618 // Type or member is obsolete
&& ((entityType as IConventionEntityType)?.GetSqlQueryConfigurationSource() == null)
? GetDefaultViewName(entityType)
: null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ public override void ProcessModelFinalizing(
{
entityType.SetQueryFilter((LambdaExpression)DbSetAccessRewriter.Rewrite(modelBuilder.Metadata, queryFilter));
}

#pragma warning disable CS0618 // Type or member is obsolete
var definingQuery = ((IEntityType)entityType).GetDefiningQuery();
if (definingQuery != null)
{
entityType.SetDefiningQuery((LambdaExpression)DbSetAccessRewriter.Rewrite(modelBuilder.Metadata, definingQuery));
}
#pragma warning restore CS0618 // Type or member is obsolete
}
}

Expand Down
38 changes: 0 additions & 38 deletions src/EFCore/Extensions/ConventionEntityTypeExtensions.cs

This file was deleted.

23 changes: 0 additions & 23 deletions src/EFCore/Extensions/EntityTypeExtensions.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/EFCore/Extensions/MutableEntityTypeExtensions.cs

This file was deleted.

Loading
Loading