From 91c4d350e12517848a03c7864da4be86de998c4b Mon Sep 17 00:00:00 2001 From: Wvader <34067397+wvader@users.noreply.github.com> Date: Tue, 27 Dec 2022 10:41:41 +0000 Subject: [PATCH] Expose entity type full name to more templates --- .../EfMethodsSource/EfAddEntityTemplateSource.cs | 3 ++- .../EfMethodsSource/EfAddToListTemplateSource.cs | 3 ++- .../EfMethodsSource/EfGetListTemplateSource.cs | 2 ++ .../EfMethodsSource/EfGetOneEntityByTemplate.cs | 3 ++- .../EfMethodsSource/EfGetOneFromListTemplateSource.cs | 3 ++- .../EfMethodsSource/EfGetOneWithTemplateSource.cs | 4 ++-- .../EfMethodsSource/EfUpdateEntityTemplateSource.cs | 2 ++ 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/BlueWest.EfMethods/EfMethodsSource/EfAddEntityTemplateSource.cs b/src/BlueWest.EfMethods/EfMethodsSource/EfAddEntityTemplateSource.cs index 19acc91..ee92c1b 100644 --- a/src/BlueWest.EfMethods/EfMethodsSource/EfAddEntityTemplateSource.cs +++ b/src/BlueWest.EfMethods/EfMethodsSource/EfAddEntityTemplateSource.cs @@ -12,8 +12,8 @@ namespace BlueWest.EfMethods var createTypeFullName = model.CreateTypeFullName; var newEntityVarName = $"new{model.EntityTypeIdentifierName}"; var toCreateVarName = $"{model.EntityTypeIdentifierName.ToCamelCase()}ToCreate"; - var entityTypeName = model.EntityTypeIdentifierName; + var entityFullTypeName = model.EntityTypeFullName; var contextFullName = methodsModel.ContextFullType; var propertyName = model.PropertyName; @@ -22,6 +22,7 @@ namespace BlueWest.EfMethods var templateToSourceBuilder = new StringBuilder(addSourceTemplate); templateToSourceBuilder .Replace("{entityTypeName}", model.EntityTypeIdentifierName) + .Replace("{entityFullTypeName}", entityFullTypeName) .Replace("{returnTypeFullName}", returnTypeFullName) .Replace("{createTypeFullName}", createTypeFullName) .Replace("{contextFullName}", contextFullName) diff --git a/src/BlueWest.EfMethods/EfMethodsSource/EfAddToListTemplateSource.cs b/src/BlueWest.EfMethods/EfMethodsSource/EfAddToListTemplateSource.cs index 8bb68ff..0906b2e 100644 --- a/src/BlueWest.EfMethods/EfMethodsSource/EfAddToListTemplateSource.cs +++ b/src/BlueWest.EfMethods/EfMethodsSource/EfAddToListTemplateSource.cs @@ -15,7 +15,7 @@ namespace BlueWest.EfMethods var listItemCreateVarName = model.ListEntityIdentifierName.ToCamelCase() + "toCreate"; var listEntityTypeName = model.ListEntityIdentifierName; var listEntityFullName = model.ListEntityFullTypeName; - + var entityFullTypeName = model.EntityTypeFullName; var contextFullName = methodsModel.ContextFullType; var propertyName = model.PropertyName; var primaryKeyFullName = model.KeyFullTypeName; @@ -31,6 +31,7 @@ namespace BlueWest.EfMethods .Replace("{returnTypeFullName}", returnTypeFullName) .Replace("{entityTypeName}", entityTypeName) .Replace("{contextFullName}", contextFullName) + .Replace("{entityFullTypeName}", entityFullTypeName) .Replace("{listPropertyName}", listPropertyName) .Replace("{primaryKeyPropertyName}", primaryKeyPropertyName) .Replace("{primaryKeyFullName}", primaryKeyFullName) diff --git a/src/BlueWest.EfMethods/EfMethodsSource/EfGetListTemplateSource.cs b/src/BlueWest.EfMethods/EfMethodsSource/EfGetListTemplateSource.cs index 012a889..8b8dbbc 100644 --- a/src/BlueWest.EfMethods/EfMethodsSource/EfGetListTemplateSource.cs +++ b/src/BlueWest.EfMethods/EfMethodsSource/EfGetListTemplateSource.cs @@ -10,6 +10,7 @@ namespace BlueWest.EfMethods { var returnTypeFullName = model.ReturnTypeFullName; var entityTypeName = model.EntityTypeIdentifierName; + var entityFullTypeName = model.EntityTypeFullName; var listPropertyName = model.ListPropertyName; var contextFullName = methodsModel.ContextFullType; var propertyName = model.PropertyName; @@ -24,6 +25,7 @@ namespace BlueWest.EfMethods templateToSourceBuilder .Replace("{returnTypeFullName}", returnTypeFullName) .Replace("{entityTypeName}", entityTypeName) + .Replace("{entityFullTypeName}", entityFullTypeName) .Replace("{contextFullName}", contextFullName) .Replace("{listPropertyName}", listPropertyName) .Replace("{primaryKeyPropertyName}", primaryKeyPropertyName) diff --git a/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneEntityByTemplate.cs b/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneEntityByTemplate.cs index 4d6c5ed..ba07751 100644 --- a/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneEntityByTemplate.cs +++ b/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneEntityByTemplate.cs @@ -19,6 +19,7 @@ namespace BlueWest.EfMethods var byParamVarName = model.ByParamPropertyName.ToCamelCase(); var findEntityVarName = model.EntityTypeIdentifierName.ToCamelCase(); var propertyName = model.PropertyName; + var entityFullTypeName = model.EntityTypeFullName; if (!addSourceTemplate.IsEmpty()) { @@ -26,9 +27,9 @@ namespace BlueWest.EfMethods templateToSourceBuilder .Replace("{returnTypeFullName}", returnTypeFullName) .Replace("{entityTypeName}", entityTypeName) + .Replace("{entityFullTypeName}", entityFullTypeName) .Replace("{byParamPropertyName}", byParamPropertyName) .Replace("{contextFullName}", contextFullName) - .Replace("{byParamFullType}", byParamFullType) .Replace("{byParamVarName}", byParamVarName) .Replace("{findEntityVarName}", findEntityVarName) diff --git a/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneFromListTemplateSource.cs b/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneFromListTemplateSource.cs index b1995fe..7738979 100644 --- a/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneFromListTemplateSource.cs +++ b/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneFromListTemplateSource.cs @@ -12,6 +12,7 @@ namespace BlueWest.EfMethods { var returnTypeFullName = model.ReturnTypeFullName; var entityTypeName = model.EntityTypeIdentifierName; + var entityFullTypeName = model.EntityTypeFullName; var propertyName = model.PropertyName; var listItemTypeName = model.ListEntityIdentifierName; @@ -36,7 +37,7 @@ namespace BlueWest.EfMethods .Replace("{contextFullName}", contextFullName) .Replace("{primaryKeyPropertyName}", primaryKeyPropertyName) .Replace("{listPrimaryKeyPropertyName}", listPrimaryKeyPropertyName) - + .Replace("{entityFullTypeName}", entityFullTypeName) .Replace("{primaryKeyFullName}", primaryKeyFullName) .Replace("{primaryKeyVarName}", primaryKeyVarName) .Replace("{listPrimaryKeyFullName}", listPrimaryKeyFullName) diff --git a/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneWithTemplateSource.cs b/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneWithTemplateSource.cs index e3ab629..e5a48fb 100644 --- a/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneWithTemplateSource.cs +++ b/src/BlueWest.EfMethods/EfMethodsSource/EfGetOneWithTemplateSource.cs @@ -16,13 +16,14 @@ namespace BlueWest.EfMethods var contextFullName = methodsModel.ContextFullType; var findEntityVarName = model.EntityTypeIdentifierName.ToCamelCase(); var propertyName = model.PropertyName; - + var entityFullTypeName = model.EntityTypeFullName; if (!addSourceTemplate.IsEmpty()) { var templateToSourceBuilder = new StringBuilder(addSourceTemplate); templateToSourceBuilder .Replace("{returnTypeFullName}", returnTypeFullName) .Replace("{entityTypeName}", entityTypeName) + .Replace("{entityFullTypeName}", entityFullTypeName) .Replace("{contextFullName}", contextFullName) .Replace("{contextFullName}", contextFullName) .Replace("{findEntityVarName}", findEntityVarName) @@ -68,7 +69,6 @@ namespace BlueWest.EfMethods templateToSourceBuilder .Replace("{returnTypeFullName}", returnTypeFullName) .Replace("{entityFullTypeName}", entityFullTypeName) - .Replace("{entityTypeName}", entityTypeName) .Replace("{contextFullName}", contextFullName) .Replace("{contextFullName}", contextFullName) diff --git a/src/BlueWest.EfMethods/EfMethodsSource/EfUpdateEntityTemplateSource.cs b/src/BlueWest.EfMethods/EfMethodsSource/EfUpdateEntityTemplateSource.cs index 1be2132..1e84b5b 100644 --- a/src/BlueWest.EfMethods/EfMethodsSource/EfUpdateEntityTemplateSource.cs +++ b/src/BlueWest.EfMethods/EfMethodsSource/EfUpdateEntityTemplateSource.cs @@ -18,6 +18,7 @@ namespace BlueWest.EfMethods.Sources var keyPropertyName = model.KeyPropertyName; var keyTypeFullName = model.KeyFullTypeName; var existingVarName = entityTypeName.ToCamelCase(); + var entityFullTypeName = model.EntityTypeFullName; var keyVarName = entityTypeName.ToCamelCase() + model.KeyPropertyName; if (!updateSourceTemplate.IsEmpty()) { @@ -30,6 +31,7 @@ namespace BlueWest.EfMethods.Sources .Replace("{contextFullName}", contextFullName) .Replace("{propertyName}", propertyName) .Replace("{keyTypeFullName}", keyTypeFullName) + .Replace("{entityFullTypeName}", entityFullTypeName) .Replace("{keyPropertyName}", keyPropertyName) .Replace("{keyVarName}", keyVarName) .Replace("{existingEntityVarName}", existingVarName);