Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/Framework.Core/PropertyPath/PropertyPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -86,6 +87,6 @@ private static IEnumerable<PropertyInfo> 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!);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ private ITypeResolver<IProjection> 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));
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Anch.Core;

using Framework.Core;
using Framework.Database.Mapping.Extensions;
using Framework.Projection.Lambda.Extensions;

Expand All @@ -15,7 +16,13 @@ public IEnumerable<IProjection> 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"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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")]
Expand Down
3 changes: 3 additions & 0 deletions src/_SampleSystem/SampleSystem.Domain/Employee/Employee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@
<property name="PeriodStartDateXXX" column="periodStartDate" type="timestamp" insert="false" update="false" access="field.camelcase" />
</join>
</class>
<class name="SampleSystem.Domain.Projections.EmployeeWithBuPeriod" table="Employee">
<id name="Id" column="id" type="Guid" access="field.camelcase">
<generator class="guid.comb" />
</id>
<many-to-one name="CoreBusinessUnit_Auto" column="coreBusinessUnitId" class="SampleSystem.Domain.Projections.EmployeeWithBuPeriod_AutoProp_CoreBusinessUnit" access="field.camelcase" insert="false" update="false" />
</class>
<class name="SampleSystem.Domain.Projections.EmployeeWithBuPeriod_AutoProp_CoreBusinessUnit" table="BusinessUnit">
<id name="Id" column="id" type="Guid" access="field.camelcase">
<generator class="guid.comb" />
</id>
<component name="Period_Last_BuPeriod" class="Framework.Core.Period, Framework.Core" access="field.camelcase">
<property name="EndDate" column="periodendDate" access="field.camelcase" type="timestamp" />
<property name="StartDate" column="periodstartDate" access="field.camelcase" type="timestamp" />
</component>
</class>
<class name="SampleSystem.Domain.Projections.HerBusinessUnit" table="BusinessUnit">
<id name="Id" column="id" type="Guid" access="field.camelcase">
<generator class="guid.comb" />
Expand Down Expand Up @@ -76,6 +91,10 @@
<generator class="guid.comb" />
</id>
<property name="PeriodStartDate_Last_ParentPeriodStartDate" column="periodStartDate" type="timestamp" insert="false" update="false" access="field.camelcase" />
<component name="Period_Last_ParentPeriod" class="Framework.Core.Period, Framework.Core" access="field.camelcase">
<property name="EndDate" column="periodendDate" access="field.camelcase" type="timestamp" />
<property name="StartDate" column="periodstartDate" access="field.camelcase" type="timestamp" />
</component>
</class>
<class name="SampleSystem.Domain.Projections.TestBusinessUnitType" table="BusinessUnitType">
<id name="Id" column="id" type="Guid" access="field.camelcase">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7884,6 +7884,8 @@ public partial class EmployeeEventRichDTO

private System.DateTime? _birthDate;

private Framework.Core.Period _buPeriod;

private bool _canBePPM;

private string _cellPhone;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -8649,6 +8664,8 @@ public partial class EmployeeEventSimpleDTO

private System.DateTime? _birthDate;

private Framework.Core.Period _buPeriod;

private bool _canBePPM;

private string _cellPhone;
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<SampleSystem.Generated.DTO.EmployeeWithBuPeriodProjectionDTO> ToProjectionDTOList(this System.Collections.Generic.IEnumerable<SampleSystem.Domain.Projections.EmployeeWithBuPeriod> 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<SampleSystem.Generated.DTO.HerBusinessUnitProjectionDTO> ToProjectionDTOList(this System.Collections.Generic.IEnumerable<SampleSystem.Domain.Projections.HerBusinessUnit> domainObjects, SampleSystem.Generated.DTO.ISampleSystemDTOMappingService mappingService)
{
return Framework.Core.CoreEnumerableExtensions.ToList(domainObjects, domainObject => SampleSystem.Generated.DTO.LambdaHelper.ToProjectionDTO(domainObject, mappingService));
Expand Down
Loading
Loading