Skip to content

Commit

Permalink
Merge pull request #226 from PHOENIXCONTACT/fix/missing-template-id
Browse files Browse the repository at this point in the history
Remove TemplateId from filtered based properties
  • Loading branch information
Toxantron authored Jan 13, 2025
2 parents db3eeb4 + 40e1676 commit 178804b
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 178804b

Please sign in to comment.