Skip to content

Commit

Permalink
Generate compiled relational model
Browse files Browse the repository at this point in the history
Fixes #24896
  • Loading branch information
AndriySvyryd committed Mar 25, 2023
1 parent 8da7a4d commit 3979c88
Show file tree
Hide file tree
Showing 69 changed files with 4,847 additions and 445 deletions.
16 changes: 8 additions & 8 deletions src/EFCore.Design/Design/Internal/CSharpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -918,14 +918,14 @@ private static string HandleEnumerable(IndentedStringBuilder builder, bool verti
/// 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 string Literal(Enum value)
public virtual string Literal(Enum value, bool fullName = false)
{
var type = value.GetType();
var name = Enum.GetName(type, value);

return name == null
? GetCompositeEnumValue(type, value)
: GetSimpleEnumValue(type, name);
? GetCompositeEnumValue(type, value, fullName)
: GetSimpleEnumValue(type, name, fullName);
}

/// <summary>
Expand All @@ -934,16 +934,16 @@ public virtual string Literal(Enum value)
/// 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>
protected virtual string GetSimpleEnumValue(Type type, string name)
=> Reference(type) + "." + name;
protected virtual string GetSimpleEnumValue(Type type, string name, bool fullName)
=> Reference(type, fullName) + "." + 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
/// 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>
protected virtual string GetCompositeEnumValue(Type type, Enum flags)
protected virtual string GetCompositeEnumValue(Type type, Enum flags, bool fullName)
{
var allValues = new HashSet<Enum>(GetFlags(flags));
foreach (var currentValue in allValues.ToList())
Expand All @@ -959,8 +959,8 @@ protected virtual string GetCompositeEnumValue(Type type, Enum flags)
(string?)null,
(previous, current) =>
previous == null
? GetSimpleEnumValue(type, Enum.GetName(type, current)!)
: previous + " | " + GetSimpleEnumValue(type, Enum.GetName(type, current)!))!;
? GetSimpleEnumValue(type, Enum.GetName(type, current)!, fullName)
: previous + " | " + GetSimpleEnumValue(type, Enum.GetName(type, current)!, fullName))!;
}

internal static IReadOnlyCollection<Enum> GetFlags(Enum flags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ private string CreateModelBuilder(
var methods = methodBuilder.ToString();
if (!string.IsNullOrEmpty(methods))
{
mainBuilder.AppendLine()
.AppendLines(methods);
mainBuilder.AppendLines(methods);
}
}

Expand Down Expand Up @@ -1465,13 +1464,18 @@ private static void CreateAnnotations<TAnnotatable>(
{
process(
annotatable,
parameters with { Annotations = annotatable.GetAnnotations().ToDictionary(a => a.Name, a => a.Value), IsRuntime = false });
parameters with
{
Annotations = annotatable.GetAnnotations().ToDictionary(a => a.Name, a => a.Value),
IsRuntime = false
});

process(
annotatable,
parameters with
{
Annotations = annotatable.GetRuntimeAnnotations().ToDictionary(a => a.Name, a => a.Value), IsRuntime = true
Annotations = annotatable.GetRuntimeAnnotations().ToDictionary(a => a.Name, a => a.Value),
IsRuntime = true
});
}

Expand Down
Loading

0 comments on commit 3979c88

Please sign in to comment.