From 535800f48159f0b7f4f1a01748351eae2611a818 Mon Sep 17 00:00:00 2001 From: "Atsuta, Ivan" Date: Thu, 4 Jun 2026 13:40:39 +0200 Subject: [PATCH] fix-projection-nullable-expand --- .../FileFactory/ProjectionFileFactory.cs | 195 +++++++++--------- .../PropertyPath/PropertyPath.cs | 5 +- .../ProjectionPropertyBuilder.cs | 2 +- .../Lambda/ProjectionLambdaEnvironment.cs | 22 +- .../ExpandPathProjectionSource.cs | 9 +- .../SampleSystem.Generated.cs | 86 ++++++++ .../SampleSystem.Domain/Employee/Employee.cs | 3 + ...ed.SampleSystem.Domain.Projections.hbm.xml | 19 ++ .../SampleSystem.Event.Generated.cs | 30 +++ .../SampleSystem.Generated.cs | 15 ++ .../SampleSystem.Helpers.Generated.cs | 10 + .../SampleSystem.Integration.Generated.cs | 30 +++ .../SampleSystem.Projections.Generated.cs | 55 +++++ .../SampleSystemMappingService.Generated.cs | 13 ++ .../SampleSystemProjectionSource.cs | 6 + src/__SolutionItems/CommonAssemblyInfo.cs | 2 +- 16 files changed, 386 insertions(+), 116 deletions(-) diff --git a/src/CodeGeneration/Framework.CodeGeneration.ProjectionGenerator/FileFactory/ProjectionFileFactory.cs b/src/CodeGeneration/Framework.CodeGeneration.ProjectionGenerator/FileFactory/ProjectionFileFactory.cs index 40c1f0df8..9057693cd 100644 --- a/src/CodeGeneration/Framework.CodeGeneration.ProjectionGenerator/FileFactory/ProjectionFileFactory.cs +++ b/src/CodeGeneration/Framework.CodeGeneration.ProjectionGenerator/FileFactory/ProjectionFileFactory.cs @@ -18,39 +18,35 @@ namespace Framework.CodeGeneration.ProjectionGenerator.FileFactory; public class ProjectionFileFactory : CodeFileFactory - where TConfiguration : class, IProjectionGeneratorConfiguration + where TConfiguration : class, IProjectionGeneratorConfiguration { private readonly bool isPersistent; private readonly Type sourceType; - private readonly Type contractType; + private readonly Type? contractType; public ProjectionFileFactory(TConfiguration configuration, Type domainType) - : base(configuration, domainType) + : base(configuration, domainType) { - this.sourceType = this.DomainType.GetProjectionSourceType(); + this.sourceType = this.DomainType!.GetProjectionSourceType()!; - this.contractType = this.DomainType.GetProjectionContractType(); + this.contractType = this.DomainType!.GetProjectionContractType(); - this.isPersistent = this.Configuration.IsPersistentObject(this.DomainType); + this.isPersistent = this.Configuration.IsPersistentObject(this.DomainType!); } public override FileType FileType { get; } = FileType.Projection; - public override CodeTypeReference BaseReference => this.Configuration.Environment.HasCustomProjectionProperties(this.DomainType) - ? this.Configuration.GetCodeTypeReference(this.DomainType, FileType.CustomProjectionBase) - : this.DomainType.BaseType.ToTypeReference(); //this.Configuration.Environment.GetProjectionBaseType(this.DomainType).ToTypeReference(); + public override CodeTypeReference BaseReference => this.Configuration.Environment.HasCustomProjectionProperties(this.DomainType!) + ? this.Configuration.GetCodeTypeReference(this.DomainType, FileType.CustomProjectionBase) + : this.DomainType!.BaseType! + .ToTypeReference(); //this.Configuration.Environment.GetProjectionBaseType(this.DomainType).ToTypeReference(); protected override CodeTypeDeclaration GetCodeTypeDeclaration() => - new() - { - Name = this.Name, - TypeAttributes = TypeAttributes.Public, - IsPartial = true, - }; + new() { Name = this.Name, TypeAttributes = TypeAttributes.Public, IsPartial = true, }; protected override IEnumerable GetBaseTypes() { @@ -59,15 +55,16 @@ protected override IEnumerable GetBaseTypes() yield return baseType; } - foreach (var @interface in this.DomainType.GetInterfaces().Except(this.DomainType.BaseType.GetInterfaces())) + foreach (var @interface in this.DomainType!.GetInterfaces().Except(this.DomainType!.BaseType!.GetInterfaces())) { yield return @interface.ToTypeReference(); } } - protected override IEnumerable GetCustomAttributes() => this.Configuration.GetDomainTypeAttributeDeclarations(this.DomainType); + protected override IEnumerable GetCustomAttributes() => this.Configuration.GetDomainTypeAttributeDeclarations(this.DomainType!); - private IEnumerable GetProperties(bool includeBase) => this.Configuration.Environment.GetProjectionProperties(this.DomainType, includeBase, false); + private IEnumerable GetProperties(bool includeBase) => + this.Configuration.Environment.GetProjectionProperties(this.DomainType!, includeBase, false); protected override IEnumerable GetMembers() { @@ -86,13 +83,10 @@ protected override IEnumerable GetMembers() { var genProp = new CodeMemberProperty { - Name = property.Name, - - Type = propertyTypeRef, - - Attributes = MemberAttributes.Public | MemberAttributes.Override, - - GetStatements = { new CodeBaseReferenceExpression().ToPropertyReference(property).ToMethodReturnStatement() } + Name = property.Name, + Type = propertyTypeRef, + Attributes = MemberAttributes.Public | MemberAttributes.Override, + GetStatements = { new CodeBaseReferenceExpression().ToPropertyReference(property).ToMethodReturnStatement() } }; genProp.CustomAttributes.AddRange(attributes); @@ -109,31 +103,27 @@ protected override IEnumerable GetMembers() } else { - var fieldType = property.PropertyType.IsCollection() ? typeof(ICollection<>).MakeGenericType(property.PropertyType.GetCollectionElementType()) : property.PropertyType; + var fieldType = property.PropertyType.IsCollection() + ? typeof(ICollection<>).MakeGenericType(property.PropertyType.GetCollectionElementType()!) + : property.PropertyType; - var genField = new CodeMemberField - { - Name = property.Name.ToStartLowerCase(), - - Type = fieldType.ToTypeReference() - }; + var genField = new CodeMemberField { Name = property.Name.ToStartLowerCase(), Type = fieldType.ToTypeReference() }; var genProp = new CodeMemberProperty { - Name = property.Name, - - Type = propertyTypeRef, - - Attributes = MemberAttributes.Public, - - GetStatements = { new CodeThisReferenceExpression().ToFieldReference(genField).ToMethodReturnStatement() } + Name = property.Name, + Type = propertyTypeRef, + Attributes = MemberAttributes.Public, + GetStatements = { new CodeThisReferenceExpression().ToFieldReference(genField).ToMethodReturnStatement() } }; genProp.CustomAttributes.AddRange(attributes); - if (this.Configuration.Environment.MetadataProxyProvider.Wrap(property).HasAttribute(mappingAttr => mappingAttr.IsOneToOne) && this.Configuration.OneToOneSetter) + if (this.Configuration.Environment.MetadataProxyProvider.Wrap(property).HasAttribute(mappingAttr => mappingAttr.IsOneToOne) + && this.Configuration.OneToOneSetter) { - genProp.SetStatements.Add(new CodePropertySetValueReferenceExpression().ToAssignStatement(new CodeThisReferenceExpression().ToFieldReference(genField))); + genProp.SetStatements.Add( + new CodePropertySetValueReferenceExpression().ToAssignStatement(new CodeThisReferenceExpression().ToFieldReference(genField))); } yield return genField; @@ -142,13 +132,13 @@ protected override IEnumerable GetMembers() } } - foreach (var interfaceType in this.DomainType.GetInterfaces()) + foreach (var interfaceType in this.DomainType!.GetInterfaces()) { var reverseInterfaceMap = this.DomainType.GetInterfaceMapDictionary(interfaceType); foreach (var privateProperty in this.DomainType.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)) { - if (reverseInterfaceMap.ContainsValue(privateProperty.GetMethod)) + if (reverseInterfaceMap.ContainsValue(privateProperty.GetMethod!)) { var genProp = this.CreateExpandProperty(privateProperty, true); @@ -164,48 +154,49 @@ private CodeMemberProperty CreateExpandProperty(PropertyInfo property, bool with { if (property == null) throw new ArgumentNullException(nameof(property)); - var expandPathAttr = property.GetCustomAttribute(); + var expandPathAttr = property.GetCustomAttribute()!; var propertyPath = this.Configuration.Environment.PropertyPathService.TryGetExpandPath(property)!; var getExpr = propertyPath.Aggregate( - new { Expression = (CodeExpression)new CodeThisReferenceExpression(), IsRef = false }, - - (state, propNode) => - { - if (state.IsRef) - { - return new { Expression = (CodeExpression)state.Expression.ToMaybePropertyReference(propNode), IsRef = true }; - } - else - { - return new { Expression = (CodeExpression)state.Expression.ToPropertyReference(propNode), IsRef = propNode.PropertyType.IsNullable() || propNode.PropertyType.IsClass }; - } - }, - state => - { - if (propertyPath.Count > 1 && property.PropertyType.IsCollection()) - { - return typeof(Anch.Core.EnumerableExtensions) - .ToTypeReferenceExpression() - .ToMethodInvokeExpression("EmptyIfNull", state.Expression); - } - else - { - return state.Expression; - } - }); + new { Expression = (CodeExpression)new CodeThisReferenceExpression(), IsRef = false }, + + (state, propNode) => + { + if (state.IsRef) + { + return new { Expression = (CodeExpression)state.Expression.ToMaybePropertyReference(propNode), IsRef = true }; + } + else + { + return new + { + Expression = (CodeExpression)state.Expression.ToPropertyReference(propNode), + IsRef = propNode.PropertyType.IsNullable() || propNode.PropertyType.IsClass + }; + } + }, + state => + { + if (propertyPath.Count > 1 && property.PropertyType.IsCollection()) + { + return typeof(Anch.Core.EnumerableExtensions) + .ToTypeReferenceExpression() + .ToMethodInvokeExpression("EmptyIfNull", state.Expression); + } + else + { + return state.Expression; + } + }); var prop = new CodeMemberProperty { - Name = property.Name, - - Type = property.PropertyType.ToTypeReference(), - - Attributes = MemberAttributes.Public, - - GetStatements = { getExpr.ToMethodReturnStatement() }, + Name = property.Name, + Type = property.PropertyType.ToTypeReference(), + Attributes = MemberAttributes.Public, + GetStatements = { getExpr.ToMethodReturnStatement() }, }; if (withAttr) @@ -219,10 +210,7 @@ private CodeMemberProperty CreateExpandProperty(PropertyInfo property, bool with protected override IEnumerable GetConstructors() { - yield return new CodeConstructor - { - Attributes = this.Configuration.GeneratePublicCtors ? MemberAttributes.Public : MemberAttributes.Family - }; + yield return new CodeConstructor { Attributes = this.Configuration.GeneratePublicCtors ? MemberAttributes.Public : MemberAttributes.Family }; if (this.contractType != null) { @@ -232,21 +220,18 @@ protected override IEnumerable GetConstructors() private CodeConstructor GetSourceConstructor() { - var parameter = this.contractType.ToTypeReference().ToParameterDeclarationExpression("source"); + var parameter = this.contractType!.ToTypeReference().ToParameterDeclarationExpression("source"); var parameterVar = parameter.ToVariableReferenceExpression(); - return new CodeConstructor - { - Attributes = MemberAttributes.Public, - Parameters = { parameter } - }.WithStatements(this.GetSourceConstructorStatements(parameterVar)); + return new CodeConstructor { Attributes = MemberAttributes.Public, Parameters = { parameter } }.WithStatements( + this.GetSourceConstructorStatements(parameterVar)); } private IEnumerable GetSourceConstructorStatements(CodeExpression sourceExpr) { var targetExpr = new CodeThisReferenceExpression(); - var baseProperties = this.contractType.GetAllInterfaceProperties(); + var baseProperties = this.contractType!.GetAllInterfaceProperties(); var basePropertiesDict = baseProperties.ToDictionary(p => p.Name); @@ -261,21 +246,24 @@ private IEnumerable GetSourceConstructorStatements(CodeExpression var sourcePropExpr = sourceExpr.ToPropertyReference(sourceProp); - var targetMemberExpr = targetProp.ReflectedType == this.DomainType ? (CodeExpression)targetExpr.ToFieldReference(targetProp.Name.ToStartLowerCase()) - : targetExpr.ToPropertyReference(targetProp); + var targetMemberExpr = targetProp.ReflectedType == this.DomainType + ? (CodeExpression)targetExpr.ToFieldReference(targetProp.Name.ToStartLowerCase()) + : targetExpr.ToPropertyReference(targetProp); if (sourceProp.PropertyType != targetProp.PropertyType) { - if (sourceProp.PropertyType.IsCollection()) + if (targetProp.PropertyType.GetCollectionElementType() is { } elementType) { - var elementType = targetProp.PropertyType.GetCollectionElementType(); - - var lambda = new CodeParameterDeclarationExpression { Name = "v" }.Pipe(param => new CodeLambdaExpression - { - Parameters = { param }, - - Statements = { elementType.ToTypeReference().ToObjectCreateExpression(param.ToVariableReferenceExpression()).ToMethodReturnStatement() } - }); + var lambda = new CodeParameterDeclarationExpression { Name = "v" } + .Pipe(param => new CodeLambdaExpression + { + Parameters = { param }, + Statements = + { + elementType.ToTypeReference().ToObjectCreateExpression(param.ToVariableReferenceExpression()) + .ToMethodReturnStatement() + } + }); yield return typeof(CoreEnumerableExtensions) .ToTypeReferenceExpression() @@ -286,10 +274,11 @@ private IEnumerable GetSourceConstructorStatements(CodeExpression { yield return new CodeNotNullConditionStatement(sourcePropExpr) { - TrueStatements = - { - targetProp.PropertyType.ToTypeReference().ToObjectCreateExpression(sourcePropExpr).ToAssignStatement(targetMemberExpr) - } + TrueStatements = + { + targetProp.PropertyType.ToTypeReference().ToObjectCreateExpression(sourcePropExpr) + .ToAssignStatement(targetMemberExpr) + } }; } } diff --git a/src/Framework.Core/PropertyPath/PropertyPath.cs b/src/Framework.Core/PropertyPath/PropertyPath.cs index 9fa965988..ffbe690fd 100644 --- a/src/Framework.Core/PropertyPath/PropertyPath.cs +++ b/src/Framework.Core/PropertyPath/PropertyPath.cs @@ -71,7 +71,8 @@ public PropertyPath Tail public static PropertyPath operator +(PropertyPath path, PropertyInfo propertyInfo) => path.Concat([propertyInfo]).ToPropertyPath(); - public static bool operator ==(PropertyPath path1, PropertyPath path2) => ReferenceEquals(path1, path2) || (!ReferenceEquals(path1, null) && path1.Equals(path2)); + public static bool operator ==(PropertyPath path1, PropertyPath path2) => + ReferenceEquals(path1, path2) || (!ReferenceEquals(path1, null) && path1.Equals(path2)); public static bool operator !=(PropertyPath path1, PropertyPath path2) => !(path1 == path2); @@ -86,6 +87,6 @@ private static IEnumerable GetProperties(Type sourceType, IEnumera { var currentType = prevProperty == null ? sourceType : prevProperty.PropertyType.GetCollectionElementTypeOrSelf(); - return currentType.GetRequiredProperty(propertyName, BindingFlags.Public | BindingFlags.Instance); + return currentType.GetRequiredProperty(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); }).Skip(1).Select(v => v!); } diff --git a/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionBuilder/ProjectionPropertyBuilder.cs b/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionBuilder/ProjectionPropertyBuilder.cs index 52e191ec1..47e57ddc9 100644 --- a/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionBuilder/ProjectionPropertyBuilder.cs +++ b/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionBuilder/ProjectionPropertyBuilder.cs @@ -50,7 +50,7 @@ public ProjectionPropertyBuilder(ProjectionLambdaEnvironment environment, Lambda public bool IsCollection => this.CollectionType != null; - public bool IsNullable { get; } + public bool IsNullable { get; set; } public Type ElementType { get; } diff --git a/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionLambdaEnvironment.cs b/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionLambdaEnvironment.cs index 300d75d9a..fead2f546 100644 --- a/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionLambdaEnvironment.cs +++ b/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionLambdaEnvironment.cs @@ -42,14 +42,15 @@ private ITypeResolver CreateProjectionTypeResolver(IProjectionSourc this.projections = [ - ..projectionSource.Pipe(v => new LinkAllProjectionSource(v)) - .Pipe(v => new ExpandPathProjectionSource(this, v)) - .Pipe(v => new VerifyUniqueProjectionSource(v)) - .Pipe(v => this.UseDependencySecurity ? (IProjectionSource)v : new CreateSecurityNodesProjectionSource(this, v)) - .Pipe(v => new CreateAutoNodesProjectionSource(this, v)) - .Pipe(v => new InjectMissedParentsProjectionSource(this, v)) - .Pipe(v => new InjectAttributesProjectionSource(this, v)) - .GetProjections() + ..projectionSource + .Pipe(v => new LinkAllProjectionSource(v)) + .Pipe(v => new ExpandPathProjectionSource(this, v)) + .Pipe(v => new VerifyUniqueProjectionSource(v)) + .Pipe(v => this.UseDependencySecurity ? (IProjectionSource)v : new CreateSecurityNodesProjectionSource(this, v)) + .Pipe(v => new CreateAutoNodesProjectionSource(this, v)) + .Pipe(v => new InjectMissedParentsProjectionSource(this, v)) + .Pipe(v => new InjectAttributesProjectionSource(this, v)) + .GetProjections() ]; return TypeResolverHelper.Create(this.projections.ToDictionary(projection => projection, this.ProjectionTypeResolver.Resolve)); @@ -109,6 +110,11 @@ internal Type BuildPropertyType(TypeReferenceBase typeReferenceBase, GeneratedTy if (generatedProjection == null) throw new ArgumentNullException(nameof(generatedProjection)); if (propertyName == null) throw new ArgumentNullException(nameof(propertyName)); + if (propertyName == "BuPeriod") + { + + } + try { return this.BuildPropertyType(typeReferenceBase); diff --git a/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionSource/ExpandPathProjectionSource.cs b/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionSource/ExpandPathProjectionSource.cs index 851fa0aff..df1dce7af 100644 --- a/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionSource/ExpandPathProjectionSource.cs +++ b/src/Projection/Framework.Projection.Runtime/Lambda/ProjectionSource/ExpandPathProjectionSource.cs @@ -1,5 +1,6 @@ using Anch.Core; +using Framework.Core; using Framework.Database.Mapping.Extensions; using Framework.Projection.Lambda.Extensions; @@ -15,7 +16,13 @@ public IEnumerable GetProjections() { foreach (var propertyBuilder in projectionBuilder.Properties) { - propertyBuilder.Path = environment.PropertyPathService.WithExpand(propertyBuilder.Path); + var newPath = environment.PropertyPathService.WithExpand(propertyBuilder.Path); + + if (newPath != propertyBuilder.Path) + { + propertyBuilder.Path = newPath; + propertyBuilder.IsNullable = propertyBuilder.Expression.ReturnType.IsValueType && propertyBuilder.Path.HasReferenceResult(); + } propertyBuilder.Path.Where(prop => !prop.IsPersistent()).Foreach(prop => throw new Exception($"Projection property \"{prop.Name}\" of path \"{propertyBuilder.Path}\" must be persistent")); } diff --git a/src/_SampleSystem/SampleSystem.Domain.Projections/SampleSystem.Generated.cs b/src/_SampleSystem/SampleSystem.Domain.Projections/SampleSystem.Generated.cs index 15fccaf74..3eb2a48f2 100644 --- a/src/_SampleSystem/SampleSystem.Domain.Projections/SampleSystem.Generated.cs +++ b/src/_SampleSystem/SampleSystem.Domain.Projections/SampleSystem.Generated.cs @@ -278,6 +278,67 @@ public virtual System.DateTime PeriodStartDateXXX } } + [Framework.BLL.Domain.Attributes.DependencySecurityAttribute(typeof(SampleSystem.Domain.Employee.Employee))] + [Framework.Database.Mapping.TableAttribute(Name="Employee")] + [Framework.Projection.ProjectionAttribute(typeof(SampleSystem.Domain.Employee.Employee), Framework.Projection.ProjectionRole.Default)] + public partial class EmployeeWithBuPeriod : SampleSystem.Domain.PersistentDomainObjectBase + { + + private SampleSystem.Domain.Projections.EmployeeWithBuPeriod_AutoProp_CoreBusinessUnit coreBusinessUnit_Auto; + + protected EmployeeWithBuPeriod() + { + } + + [Framework.Projection.ProjectionPropertyAttribute(Framework.Projection.ProjectionPropertyRole.Default)] + [Framework.BLL.Domain.Persistent.Attributes.ExpandPathAttribute("CoreBusinessUnit_Auto.Period_Last_BuPeriod")] + [Framework.Database.Mapping.MappingPropertyAttribute(CanInsert=false, CanUpdate=false)] + public virtual Framework.Core.Period? BuPeriod + { + get + { + return this.CoreBusinessUnit_Auto?.Period_Last_BuPeriod; + } + } + + [Framework.BLL.Domain.Serialization.CustomSerializationAttribute(Framework.BLL.Domain.Serialization.CustomSerializationMode.Ignore)] + [Framework.Projection.ProjectionPropertyAttribute(Framework.Projection.ProjectionPropertyRole.AutoNode)] + [Framework.Database.Mapping.MappingAttribute(ColumnName="coreBusinessUnitId")] + [Framework.Database.Mapping.MappingPropertyAttribute(CanInsert=false, CanUpdate=false)] + public virtual SampleSystem.Domain.Projections.EmployeeWithBuPeriod_AutoProp_CoreBusinessUnit CoreBusinessUnit_Auto + { + get + { + return this.coreBusinessUnit_Auto; + } + } + } + + [Framework.BLL.Domain.Attributes.DependencySecurityAttribute(typeof(SampleSystem.Domain.BU.BusinessUnit))] + [Framework.Database.Mapping.TableAttribute(Name="BusinessUnit")] + [Framework.Projection.ProjectionAttribute(typeof(SampleSystem.Domain.BU.BusinessUnit), Framework.Projection.ProjectionRole.AutoNode)] + public partial class EmployeeWithBuPeriod_AutoProp_CoreBusinessUnit : SampleSystem.Domain.PersistentDomainObjectBase + { + + private Framework.Core.Period period_Last_BuPeriod; + + protected EmployeeWithBuPeriod_AutoProp_CoreBusinessUnit() + { + } + + [Framework.BLL.Domain.Serialization.CustomSerializationAttribute(Framework.BLL.Domain.Serialization.CustomSerializationMode.Ignore)] + [Framework.Projection.ProjectionPropertyAttribute(Framework.Projection.ProjectionPropertyRole.LastAutoNode)] + [Framework.Database.Mapping.MappingAttribute(ColumnName="period")] + [Framework.Database.Mapping.MappingPropertyAttribute(CanInsert=false, CanUpdate=false)] + public virtual Framework.Core.Period Period_Last_BuPeriod + { + get + { + return this.period_Last_BuPeriod; + } + } + } + [Framework.BLL.Domain.Attributes.DependencySecurityAttribute(typeof(SampleSystem.Domain.BU.BusinessUnit))] [Framework.Database.Mapping.TableAttribute(Name="BusinessUnit")] [Framework.Projection.ProjectionAttribute(typeof(SampleSystem.Domain.BU.BusinessUnit), Framework.Projection.ProjectionRole.Default)] @@ -516,6 +577,17 @@ public virtual SampleSystem.Domain.Projections.TestBusinessUnit_AutoProp_Parent } } + [Framework.Projection.ProjectionPropertyAttribute(Framework.Projection.ProjectionPropertyRole.Default)] + [Framework.BLL.Domain.Persistent.Attributes.ExpandPathAttribute("Parent_Auto.Period_Last_ParentPeriod")] + [Framework.Database.Mapping.MappingPropertyAttribute(CanInsert=false, CanUpdate=false)] + public virtual Framework.Core.Period? ParentPeriod + { + get + { + return this.Parent_Auto?.Period_Last_ParentPeriod; + } + } + [Framework.Projection.ProjectionPropertyAttribute(Framework.Projection.ProjectionPropertyRole.Default)] [Framework.BLL.Domain.Persistent.Attributes.ExpandPathAttribute("Parent_Auto.PeriodStartDate_Last_ParentPeriodStartDate")] [Framework.Database.Mapping.MappingPropertyAttribute(CanInsert=false, CanUpdate=false)] @@ -545,12 +617,26 @@ public virtual System.DateTime? PeriodEndDate public partial class TestBusinessUnit_AutoProp_Parent : SampleSystem.Domain.PersistentDomainObjectBase { + private Framework.Core.Period period_Last_ParentPeriod; + private System.DateTime periodStartDate_Last_ParentPeriodStartDate; protected TestBusinessUnit_AutoProp_Parent() { } + [Framework.BLL.Domain.Serialization.CustomSerializationAttribute(Framework.BLL.Domain.Serialization.CustomSerializationMode.Ignore)] + [Framework.Projection.ProjectionPropertyAttribute(Framework.Projection.ProjectionPropertyRole.LastAutoNode)] + [Framework.Database.Mapping.MappingAttribute(ColumnName="period")] + [Framework.Database.Mapping.MappingPropertyAttribute(CanInsert=false, CanUpdate=false)] + public virtual Framework.Core.Period Period_Last_ParentPeriod + { + get + { + return this.period_Last_ParentPeriod; + } + } + [Framework.BLL.Domain.Serialization.CustomSerializationAttribute(Framework.BLL.Domain.Serialization.CustomSerializationMode.Ignore)] [Framework.Projection.ProjectionPropertyAttribute(Framework.Projection.ProjectionPropertyRole.LastAutoNode)] [Framework.Database.Mapping.MappingAttribute(ColumnName="periodStartDate")] diff --git a/src/_SampleSystem/SampleSystem.Domain/Employee/Employee.cs b/src/_SampleSystem/SampleSystem.Domain/Employee/Employee.cs index d524321d9..2cde3891e 100644 --- a/src/_SampleSystem/SampleSystem.Domain/Employee/Employee.cs +++ b/src/_SampleSystem/SampleSystem.Domain/Employee/Employee.cs @@ -261,6 +261,9 @@ public virtual DateTime? HireDate //// set { this.address = value; } ////} + [ExpandPath("CoreBusinessUnit.Period")] + public virtual Period BuPeriod => this.CoreBusinessUnit.Maybe(v => v.Period); + [ExpandPath("HRDepartment.Location")] public virtual Location Location => this.HRDepartment?.Location; diff --git a/src/_SampleSystem/SampleSystem.Generated.DAL.NHibernate/Mapping/Generated.SampleSystem.Domain.Projections.hbm.xml b/src/_SampleSystem/SampleSystem.Generated.DAL.NHibernate/Mapping/Generated.SampleSystem.Domain.Projections.hbm.xml index 1f7c6f46c..4aee159d0 100644 --- a/src/_SampleSystem/SampleSystem.Generated.DAL.NHibernate/Mapping/Generated.SampleSystem.Domain.Projections.hbm.xml +++ b/src/_SampleSystem/SampleSystem.Generated.DAL.NHibernate/Mapping/Generated.SampleSystem.Domain.Projections.hbm.xml @@ -44,6 +44,21 @@ + + + + + + + + + + + + + + + @@ -76,6 +91,10 @@ + + + + diff --git a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Event.Generated.cs b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Event.Generated.cs index cf46e02dd..11552a10d 100644 --- a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Event.Generated.cs +++ b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Event.Generated.cs @@ -7884,6 +7884,8 @@ public partial class EmployeeEventRichDTO private System.DateTime? _birthDate; + private Framework.Core.Period _buPeriod; + private bool _canBePPM; private string _cellPhone; @@ -8037,6 +8039,19 @@ public System.DateTime? BirthDate } } + [System.Runtime.Serialization.DataMemberAttribute()] + public Framework.Core.Period BuPeriod + { + get + { + return this._buPeriod; + } + set + { + this._buPeriod = value; + } + } + [System.Runtime.Serialization.DataMemberAttribute()] public bool CanBePPM { @@ -8649,6 +8664,8 @@ public partial class EmployeeEventSimpleDTO private System.DateTime? _birthDate; + private Framework.Core.Period _buPeriod; + private bool _canBePPM; private string _cellPhone; @@ -8772,6 +8789,19 @@ public System.DateTime? BirthDate } } + [System.Runtime.Serialization.DataMemberAttribute()] + public Framework.Core.Period BuPeriod + { + get + { + return this._buPeriod; + } + set + { + this._buPeriod = value; + } + } + [System.Runtime.Serialization.DataMemberAttribute()] public bool CanBePPM { diff --git a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Generated.cs b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Generated.cs index 3c2fcbd31..247f4358c 100644 --- a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Generated.cs +++ b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Generated.cs @@ -14165,6 +14165,8 @@ public partial class EmployeeSimpleDTO : SampleSystem.Generated.DTO.BaseAuditPer private System.DateTime? _birthDate; + private Framework.Core.Period _buPeriod = Framework.Core.Period.Eternity; + private bool _canBePPM; private string _cellPhone; @@ -14269,6 +14271,19 @@ public System.DateTime? BirthDate } } + [System.Runtime.Serialization.DataMemberAttribute()] + public Framework.Core.Period BuPeriod + { + get + { + return this._buPeriod; + } + set + { + this._buPeriod = value; + } + } + [System.Runtime.Serialization.DataMemberAttribute()] public bool CanBePPM { diff --git a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Helpers.Generated.cs b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Helpers.Generated.cs index 2271cff6a..1ad3e5748 100644 --- a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Helpers.Generated.cs +++ b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Helpers.Generated.cs @@ -1401,6 +1401,11 @@ public static SampleSystem.Generated.DTO.CustomTestObjForNestedProjectionDTO ToP return new SampleSystem.Generated.DTO.CustomTestObjForNestedProjectionDTO(mappingService, domainObject); } + public static SampleSystem.Generated.DTO.EmployeeWithBuPeriodProjectionDTO ToProjectionDTO(this SampleSystem.Domain.Projections.EmployeeWithBuPeriod domainObject, SampleSystem.Generated.DTO.ISampleSystemDTOMappingService mappingService) + { + return new SampleSystem.Generated.DTO.EmployeeWithBuPeriodProjectionDTO(mappingService, domainObject); + } + public static SampleSystem.Generated.DTO.HerBusinessUnitProjectionDTO ToProjectionDTO(this SampleSystem.Domain.Projections.HerBusinessUnit domainObject, SampleSystem.Generated.DTO.ISampleSystemDTOMappingService mappingService) { return new SampleSystem.Generated.DTO.HerBusinessUnitProjectionDTO(mappingService, domainObject); @@ -1506,6 +1511,11 @@ public static SampleSystem.Generated.DTO.VisualProjectProjectionDTO ToProjection return Framework.Core.CoreEnumerableExtensions.ToList(domainObjects, domainObject => SampleSystem.Generated.DTO.LambdaHelper.ToProjectionDTO(domainObject, mappingService)); } + public static System.Collections.Generic.List ToProjectionDTOList(this System.Collections.Generic.IEnumerable domainObjects, SampleSystem.Generated.DTO.ISampleSystemDTOMappingService mappingService) + { + return Framework.Core.CoreEnumerableExtensions.ToList(domainObjects, domainObject => SampleSystem.Generated.DTO.LambdaHelper.ToProjectionDTO(domainObject, mappingService)); + } + public static System.Collections.Generic.List ToProjectionDTOList(this System.Collections.Generic.IEnumerable domainObjects, SampleSystem.Generated.DTO.ISampleSystemDTOMappingService mappingService) { return Framework.Core.CoreEnumerableExtensions.ToList(domainObjects, domainObject => SampleSystem.Generated.DTO.LambdaHelper.ToProjectionDTO(domainObject, mappingService)); diff --git a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Integration.Generated.cs b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Integration.Generated.cs index c96243b24..8dd4fb5da 100644 --- a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Integration.Generated.cs +++ b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Integration.Generated.cs @@ -915,6 +915,8 @@ public partial class EmployeeIntegrationRichDTO : Framework.BLL.DTOMapping.Mappi private System.DateTime? _birthDate; + private Framework.Core.Period _buPeriod; + private bool _canBePPM; private string _cellPhone; @@ -1066,6 +1068,19 @@ public System.DateTime? BirthDate } } + [System.Runtime.Serialization.DataMemberAttribute()] + public Framework.Core.Period BuPeriod + { + get + { + return this._buPeriod; + } + set + { + this._buPeriod = value; + } + } + [System.Runtime.Serialization.DataMemberAttribute()] public bool CanBePPM { @@ -1697,6 +1712,8 @@ public partial class EmployeeIntegrationSimpleDTO : Framework.BLL.DTOMapping.Map private System.DateTime? _birthDate; + private Framework.Core.Period _buPeriod; + private bool _canBePPM; private string _cellPhone; @@ -1818,6 +1835,19 @@ public System.DateTime? BirthDate } } + [System.Runtime.Serialization.DataMemberAttribute()] + public Framework.Core.Period BuPeriod + { + get + { + return this._buPeriod; + } + set + { + this._buPeriod = value; + } + } + [System.Runtime.Serialization.DataMemberAttribute()] public bool CanBePPM { diff --git a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Projections.Generated.cs b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Projections.Generated.cs index 7a229c3e5..34293973b 100644 --- a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Projections.Generated.cs +++ b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystem.Projections.Generated.cs @@ -346,6 +346,46 @@ public System.DateTime PeriodStartDateXXX } } + [Framework.BLL.Domain.DTO.DTOFileTypeAttribute(typeof(SampleSystem.Domain.Projections.EmployeeWithBuPeriod), "ProjectionDTO", Framework.BLL.Domain.Serialization.DTORole.Client)] + [System.Runtime.Serialization.DataContractAttribute(Namespace="SampleSystem")] + public partial class EmployeeWithBuPeriodProjectionDTO : SampleSystem.Generated.DTO.BasePersistentDTO, Framework.BLL.Domain.IdentityObject.IIdentityObjectContainer + { + + private Framework.Core.Period? _buPeriod; + + public EmployeeWithBuPeriodProjectionDTO() + { + } + + public EmployeeWithBuPeriodProjectionDTO(SampleSystem.Generated.DTO.ISampleSystemDTOMappingService mappingService, SampleSystem.Domain.Projections.EmployeeWithBuPeriod domainObject) : + base(mappingService, domainObject) + { + mappingService.MapEmployeeWithBuPeriod(domainObject, this); + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public Framework.Core.Period? BuPeriod + { + get + { + return this._buPeriod; + } + set + { + this._buPeriod = value; + } + } + + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public SampleSystem.Generated.DTO.EmployeeIdentityDTO Identity + { + get + { + return new SampleSystem.Generated.DTO.EmployeeIdentityDTO(this.Id); + } + } + } + [Framework.BLL.Domain.DTO.DTOFileTypeAttribute(typeof(SampleSystem.Domain.Projections.HerBusinessUnit), "ProjectionDTO", Framework.BLL.Domain.Serialization.DTORole.Client)] [System.Runtime.Serialization.DataContractAttribute(Namespace="SampleSystem")] public partial class HerBusinessUnitProjectionDTO : SampleSystem.Generated.DTO.BasePersistentDTO, Framework.BLL.Domain.IdentityObject.IIdentityObjectContainer @@ -534,6 +574,8 @@ public partial class TestBusinessUnitProjectionDTO : SampleSystem.Generated.DTO. private string _name; + private Framework.Core.Period? _parentPeriod; + private System.DateTime? _parentPeriodStartDate; private System.DateTime? _periodEndDate; @@ -635,6 +677,19 @@ public string Name } } + [System.Runtime.Serialization.DataMemberAttribute()] + public Framework.Core.Period? ParentPeriod + { + get + { + return this._parentPeriod; + } + set + { + this._parentPeriod = value; + } + } + [System.Runtime.Serialization.DataMemberAttribute()] public System.DateTime? ParentPeriodStartDate { diff --git a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystemMappingService.Generated.cs b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystemMappingService.Generated.cs index 4b4c4af9f..d42bb19f3 100644 --- a/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystemMappingService.Generated.cs +++ b/src/_SampleSystem/SampleSystem.Generated.DTO/SampleSystemMappingService.Generated.cs @@ -412,6 +412,8 @@ public partial interface ISampleSystemDTOMappingService : Framework.BLL.DTOMappi void MapEmployeeToEmployeeLink(SampleSystem.Domain.Employee.EmpoloyeeLink.EmployeeToEmployeeLink domainObject, SampleSystem.Generated.DTO.EmployeeToEmployeeLinkEventRichDTO mappingObject); + void MapEmployeeWithBuPeriod(SampleSystem.Domain.Projections.EmployeeWithBuPeriod domainObject, SampleSystem.Generated.DTO.EmployeeWithBuPeriodProjectionDTO mappingObject); + void MapExample1(SampleSystem.Domain.ForUpdate.Example1 domainObject, SampleSystem.Generated.DTO.Example1SimpleDTO mappingObject); void MapExample1(SampleSystem.Domain.ForUpdate.Example1 domainObject, SampleSystem.Generated.DTO.Example1FullDTO mappingObject); @@ -2774,6 +2776,7 @@ public virtual void MapEmployee(SampleSystem.Domain.Employee.Employee domainObje mappingObject.AccountName = domainObject.AccountName; mappingObject.Age = domainObject.Age; mappingObject.BirthDate = domainObject.BirthDate; + mappingObject.BuPeriod = domainObject.BuPeriod; mappingObject.CanBePPM = domainObject.CanBePPM; mappingObject.CellPhone = domainObject.CellPhone; mappingObject.CoreBusinessUnitPeriod = domainObject.CoreBusinessUnitPeriod; @@ -3238,6 +3241,7 @@ public virtual void MapEmployee(SampleSystem.Domain.Employee.Employee domainObje mappingObject.Active = domainObject.Active; mappingObject.Age = domainObject.Age; mappingObject.BirthDate = domainObject.BirthDate; + mappingObject.BuPeriod = domainObject.BuPeriod; mappingObject.CanBePPM = domainObject.CanBePPM; mappingObject.CellPhone = domainObject.CellPhone; mappingObject.CellPhones = SampleSystem.Generated.DTO.LambdaHelper.ToRichIntegrationDTOList(domainObject.CellPhones, this); @@ -3458,6 +3462,7 @@ public virtual void MapEmployee(SampleSystem.Domain.Employee.Employee domainObje mappingObject.Active = domainObject.Active; mappingObject.Age = domainObject.Age; mappingObject.BirthDate = domainObject.BirthDate; + mappingObject.BuPeriod = domainObject.BuPeriod; mappingObject.CanBePPM = domainObject.CanBePPM; mappingObject.CellPhone = domainObject.CellPhone; mappingObject.CoreBusinessUnitPeriod = domainObject.CoreBusinessUnitPeriod; @@ -3519,6 +3524,7 @@ public virtual void MapEmployee(SampleSystem.Domain.Employee.Employee domainObje mappingObject.Active = domainObject.Active; mappingObject.Age = domainObject.Age; mappingObject.BirthDate = domainObject.BirthDate; + mappingObject.BuPeriod = domainObject.BuPeriod; mappingObject.CanBePPM = domainObject.CanBePPM; mappingObject.CellPhone = domainObject.CellPhone; mappingObject.CellPhones = SampleSystem.Generated.DTO.LambdaHelper.ToRichEventDTOList(domainObject.CellPhones, this); @@ -3657,6 +3663,7 @@ public virtual void MapEmployee(SampleSystem.Domain.Employee.Employee domainObje mappingObject.Active = domainObject.Active; mappingObject.Age = domainObject.Age; mappingObject.BirthDate = domainObject.BirthDate; + mappingObject.BuPeriod = domainObject.BuPeriod; mappingObject.CanBePPM = domainObject.CanBePPM; mappingObject.CellPhone = domainObject.CellPhone; mappingObject.CoreBusinessUnitPeriod = domainObject.CoreBusinessUnitPeriod; @@ -4733,6 +4740,11 @@ public virtual void MapEmployeeToEmployeeLink(SampleSystem.Domain.Employee.Empol mappingObject.Version = domainObject.Version; } + public virtual void MapEmployeeWithBuPeriod(SampleSystem.Domain.Projections.EmployeeWithBuPeriod domainObject, SampleSystem.Generated.DTO.EmployeeWithBuPeriodProjectionDTO mappingObject) + { + mappingObject.BuPeriod = domainObject.BuPeriod; + } + public virtual void MapExample1(SampleSystem.Domain.ForUpdate.Example1 domainObject, SampleSystem.Generated.DTO.Example1SimpleDTO mappingObject) { mappingObject.Field1 = domainObject.Field1; @@ -6635,6 +6647,7 @@ public virtual void MapTestBusinessUnit(SampleSystem.Domain.Projections.TestBusi mappingObject.Employees = domainObject.Employees; mappingObject.HerBusinessUnit_Full = domainObject.HerBusinessUnit_Full; mappingObject.Name = domainObject.Name; + mappingObject.ParentPeriod = domainObject.ParentPeriod; mappingObject.ParentPeriodStartDate = domainObject.ParentPeriodStartDate; mappingObject.PeriodEndDate = domainObject.PeriodEndDate; } diff --git a/src/_SampleSystem/_Tests/SampleSystem.CodeGenerate/Configurations/_ProjectionSources/SampleSystemProjectionSource.cs b/src/_SampleSystem/_Tests/SampleSystem.CodeGenerate/Configurations/_ProjectionSources/SampleSystemProjectionSource.cs index 66c4c0441..c8570a505 100644 --- a/src/_SampleSystem/_Tests/SampleSystem.CodeGenerate/Configurations/_ProjectionSources/SampleSystemProjectionSource.cs +++ b/src/_SampleSystem/_Tests/SampleSystem.CodeGenerate/Configurations/_ProjectionSources/SampleSystemProjectionSource.cs @@ -50,6 +50,8 @@ public SampleSystemProjectionSource() .Property(bu => bu.Parent.Period.StartDate) + .Property(bu => bu.Parent.Period) + .Property(bu => bu, () => this.HerBusinessUnit, "Her", ignoreSerialization: true) .CustomProperty("HerBusinessUnit_Full") // Расчётное свойство типа "string" @@ -152,6 +154,8 @@ public SampleSystemProjectionSource() this.TestCustomContextSecurityObjProjection = new Projection(() => this.TestCustomContextSecurityObjProjection, true) .Property(item => item.Name); + + this.EmployeeWithBuPeriod = new Projection(nameof(this.EmployeeWithBuPeriod)).Property(e => e.BuPeriod); } public Projection TestCustomContextSecurityObjProjection { get; } @@ -160,6 +164,8 @@ public SampleSystemProjectionSource() public Projection TestEmployee { get; } + public Projection EmployeeWithBuPeriod { get; } + public Projection TestIMRequest { get; } public Projection TestIMRequestDetail { get; } diff --git a/src/__SolutionItems/CommonAssemblyInfo.cs b/src/__SolutionItems/CommonAssemblyInfo.cs index 1d32b0082..7f4bb4e15 100644 --- a/src/__SolutionItems/CommonAssemblyInfo.cs +++ b/src/__SolutionItems/CommonAssemblyInfo.cs @@ -4,7 +4,7 @@ [assembly: AssemblyCompany("Luxoft")] [assembly: AssemblyCopyright("Copyright © Luxoft 2009-2026")] -[assembly: AssemblyVersion("27.2.8.0")] +[assembly: AssemblyVersion("27.2.9.0")] #if DEBUG [assembly: AssemblyConfiguration("Debug")]