Skip to content

Commit

Permalink
Remove TemplateId from filtered based properties
Browse files Browse the repository at this point in the history
Before, the GenericEntityMapper filtered all base Properties of ProductionRecipe including the TemplateId. We know add the TemplateId to the generated config mappers, which generates a mapping to one of the integer columns.
  • Loading branch information
1nf0rmagician committed Jan 9, 2025
1 parent 9af4aca commit 40e1676
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Moryx.AbstractionLayer.Recipes;
using Moryx.Container;
using Moryx.Products.Model;
using Moryx.Serialization;
Expand Down Expand Up @@ -39,12 +40,21 @@ public void Initialize(Type concreteType, IGenericMapperConfiguration config)
var jsonColumn = typeof(IGenericColumns).GetProperty(config.JsonColumn);
_jsonAccessor = ReflectionTool.PropertyAccessor<IGenericColumns, string>(jsonColumn);

var baseProperties = typeof(TBase).GetProperties().Select(p => p.Name).ToArray();
var baseProperties = typeof(TBase).GetProperties().Select(p => p.Name).ToList();
var configuredProperties = config.PropertyConfigs.Select(cm => cm.PropertyName);

var readOnlyProperties = concreteType.GetProperties()
.Where(p => p.GetSetMethod() == null).Select(p => p.Name).ToArray();

// As the IRecipeTemplating is a later addition to the base type which does not have
// a didicated database column, it is filtered by the baseProperties but not stored in
// the baseProperties columns. This is resolved in MORYX 6 due to the integration of the
// interface in the IRecipe interface and, hence, only excplicitly tackled in here.
if (typeof(IRecipeTemplating).IsAssignableFrom(typeof(TBase)))
{
baseProperties.RemoveBy(p => p == nameof(IRecipeTemplating.TemplateId));
}

// The json should not contain base, configured nor readonly properties
var jsonIgnoredProperties = baseProperties
.Concat(configuredProperties)
Expand Down

0 comments on commit 40e1676

Please sign in to comment.