Erweiterung der Übersetzungen

"1582c2b1-cef2-4d56-bb3d-1bdcf8aa9de6";"Responsible";"Responsible";"";"";"";"False";"0"
"507E00CC-9520-4095-8528-17FF9DBE22CB";"Engine Part";"Engine Part";"";"";"";"False";"0"

Erweiterung EnumRelationType

namespace BA.Training.Enums.Extensions
{
    [EnumExtension(typeof(EnumRelationType))]
    public static class EnumRelationTypeExtension
    {
        public const string ResponsibleGuid = "495F5CC6-8C75-4B55-A600-531BC49FE416";
        public static readonly EnumRelationType Responsible = new EnumRelationType(ResponsibleGuid, 1000, "1582C2B1-CEF2-4D56-BB3D-1BDCF8AA9DE6", nameof(Responsible));
    }
}

Erweiterung EnumParentRelationSubtypes

namespace BA.Training.Enums.Extensions
{
    [EnumExtension(typeof(EnumParentRelationSubtypes))]
    public class EnumParentRelationSubtypesExtension
    {
        public const string EnginePartGuid = "7FAFF96A-2A30-49E7-8BC7-75BB70731858";
        public static readonly EnumParentRelationSubtypes EnginePart = new EnumParentRelationSubtypes(EnginePartGuid, 1000, "507E00CC-9520-4095-8528-17FF9DBE22CB", nameof(EnginePart));
    }
}

Erstellung des Relationtyps

namespace BA.Training
{
    public class RelationCreation : IRelationCreation
    {
        public void CreateRelationConfigurations(KeyedDictionary<Guid, RelationTypeConfiguration> relationConfigurations)
        {
            relationConfigurations.Add(ResponsibleRelation());
        }

        private RelationTypeConfiguration ResponsibleRelation()
        {
            RelationTypeConfiguration relationConfiguration = new RelationTypeConfiguration()
            {
                Id = EnumRelationTypeExtension.Responsible,
            };

            relationConfiguration.Initialize();

            relationConfiguration.SourceTypes.Add(EnumDataSource.UserProfileGuid);
            relationConfiguration.ConfigurationName = "Responsible";
            relationConfiguration.Description = "Responsible relation";
            relationConfiguration.ShowInDesigner = true;

            return relationConfiguration;
        }
    }
}

Erweiterung OrmEngine

[Newtonsoft.Json.JsonIgnore]
[DontShowFieldInDesigner]
[RelationDefinitionTarget("67D7204E-EE21-4926-B2F7-A9E82A5B8552", EnumRelationTypeExtension.ResponsibleGuid, MinCount = 0, MaxCount = 1)]
public OrmUserProfile RelatedResponsible
{
    get
    {
        return GetSourcePrimary<OrmUserProfile>(EnumRelationTypeExtension.Responsible);
    }
}

[Newtonsoft.Json.JsonIgnore]
[DontShowFieldInDesigner]
[RelationDefinitionTarget("00016884-8F07-40A0-BB20-A15C623C197C", EnumRelationType.ParentGuid, EnumParentRelationSubtypesExtension.EnginePartGuid, MinCount = 0, MaxCount = 0)]
public IQueryable<OrmEngine> RelatedMainEngines
{
    get
    {
        return GetSources<OrmEngine>(EnumRelationType.Parent, EnumParentRelationSubtypesExtension.EnginePart);
    }
}

[Newtonsoft.Json.JsonIgnore]
[DontShowFieldInDesigner]
[RelationDefinitionSource("00016884-8F07-40A0-BB20-A15C623C197C")]
public IQueryable<OrmEngine> RelatedEngineParts
{
    get
    {
        return GetTargets<OrmEngine>(EnumRelationType.Parent, EnumParentRelationSubtypesExtension.EnginePart);
    }
}

Inject der Relationsdefinition

[assembly: RelationDefinitionSourceInject(typeof(OrmUserProfile), "RelatedResponsibleOfEngines", "67D7204E-EE21-4926-B2F7-A9E82A5B8552")]