mirror of
https://github.com/fergalmoran/EFCore.NamingConventions.git
synced 2025-12-22 09:38:21 +00:00
@@ -3,7 +3,7 @@ using Xunit;
|
|||||||
|
|
||||||
namespace EFCore.Naming.Test
|
namespace EFCore.Naming.Test
|
||||||
{
|
{
|
||||||
public class LowerNamingTest
|
public class LowerCaseNamingTest
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Table_name_is_rewritten()
|
public void Table_name_is_rewritten()
|
||||||
@@ -3,7 +3,7 @@ using Xunit;
|
|||||||
|
|
||||||
namespace EFCore.Naming.Test
|
namespace EFCore.Naming.Test
|
||||||
{
|
{
|
||||||
public class SnakeNamingTest
|
public class SnakeCaseNamingTest
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Table_name_is_rewritten()
|
public void Table_name_is_rewritten()
|
||||||
@@ -7,11 +7,11 @@ namespace EFCore.NamingConventions.Internal
|
|||||||
class LowerCaseNameRewriter : NameRewriterBase
|
class LowerCaseNameRewriter : NameRewriterBase
|
||||||
{
|
{
|
||||||
public override void ProcessEntityTypeAdded(
|
public override void ProcessEntityTypeAdded(
|
||||||
IConventionEntityTypeBuilder entityTypeBuilder,
|
IConventionEntityTypeBuilder entityTypeBuilder,
|
||||||
IConventionContext<IConventionEntityTypeBuilder> context)
|
IConventionContext<IConventionEntityTypeBuilder> context)
|
||||||
=> entityTypeBuilder.ToTable(
|
=> entityTypeBuilder.ToTable(
|
||||||
entityTypeBuilder.Metadata.GetTableName().ToLowerInvariant(),
|
entityTypeBuilder.Metadata.GetTableName().ToLowerInvariant(),
|
||||||
entityTypeBuilder.Metadata.GetSchema());
|
entityTypeBuilder.Metadata.GetSchema());
|
||||||
|
|
||||||
public override void ProcessPropertyAdded(
|
public override void ProcessPropertyAdded(
|
||||||
IConventionPropertyBuilder propertyBuilder,
|
IConventionPropertyBuilder propertyBuilder,
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ namespace EFCore.NamingConventions.Internal
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
SnakeCase,
|
SnakeCase,
|
||||||
AllLowerCase,
|
LowerCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace EFCore.NamingConventions.Internal
|
|||||||
NameRewriterBase nameRewriter = namingStyle switch
|
NameRewriterBase nameRewriter = namingStyle switch
|
||||||
{
|
{
|
||||||
NamingConvention.SnakeCase => new SnakeCaseNameRewriter(),
|
NamingConvention.SnakeCase => new SnakeCaseNameRewriter(),
|
||||||
NamingConvention.AllLowerCase => new LowerCaseNameRewriter(),
|
NamingConvention.LowerCase => new LowerCaseNameRewriter(),
|
||||||
_ => throw new NotImplementedException("Unhandled enum value: " + namingStyle)
|
_ => throw new NotImplementedException("Unhandled enum value: " + namingStyle)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace EFCore.NamingConventions.Internal
|
|||||||
public virtual NamingConventionsOptionsExtension WithLowerCaseNamingConvention()
|
public virtual NamingConventionsOptionsExtension WithLowerCaseNamingConvention()
|
||||||
{
|
{
|
||||||
var clone = Clone();
|
var clone = Clone();
|
||||||
clone._namingConvention = NamingConvention.AllLowerCase;
|
clone._namingConvention = NamingConvention.LowerCase;
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,14 +64,14 @@ namespace EFCore.NamingConventions.Internal
|
|||||||
=> _logFragment ??= Extension._namingConvention switch
|
=> _logFragment ??= Extension._namingConvention switch
|
||||||
{
|
{
|
||||||
NamingConvention.SnakeCase => "using snake-case naming ",
|
NamingConvention.SnakeCase => "using snake-case naming ",
|
||||||
NamingConvention.AllLowerCase => "using lower case naming",
|
NamingConvention.LowerCase => "using lower case naming",
|
||||||
_ => ""
|
_ => ""
|
||||||
};
|
};
|
||||||
|
|
||||||
public override long GetServiceProviderHashCode() => Extension._namingConvention.GetHashCode();
|
public override long GetServiceProviderHashCode() => Extension._namingConvention.GetHashCode();
|
||||||
|
|
||||||
public override void PopulateDebugInfo(IDictionary<string, string> debugInfo)
|
public override void PopulateDebugInfo(IDictionary<string, string> debugInfo)
|
||||||
=> debugInfo["Naming:" + nameof(NamingConventionsOptionsExtension)]
|
=> debugInfo["Naming:UseNamingConvention"]
|
||||||
= Extension._namingConvention.GetHashCode().ToString(CultureInfo.InvariantCulture);
|
= Extension._namingConvention.GetHashCode().ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user