Skip to content

Commit

Permalink
Merge pull request #47 from circles-arrows/Bug-fixes-for-Code-Generat…
Browse files Browse the repository at this point in the history
…ion-not-working-with-virtual-and-abstract-Entities

Code generation fixes for virtual and abstract Entities
  • Loading branch information
agentsmith41 authored Feb 26, 2024
2 parents fe69296 + 4e7060f commit ae5f71e
Show file tree
Hide file tree
Showing 13 changed files with 2,760 additions and 842 deletions.
10 changes: 5 additions & 5 deletions Blueprint41/Blueprint41.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,6 @@
</ItemGroup>

<ItemGroup>
<Compile Update="DatastoreTemplates\Domain_Data_Entity_Relation.cs">
<DependentUpon>Domain_Data_Entity_Relation.tt</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="DatastoreTemplates\Domain_Data_Entity.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand All @@ -238,6 +233,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>Domain_Data_Entity_Abstract.tt</DependentUpon>
</Compile>
<Compile Update="DatastoreTemplates\Domain_Data_Entity_Relation.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Domain_Data_Entity_Relation.tt</DependentUpon>
</Compile>
<Compile Update="DatastoreTemplates\Domain_Data_GraphEvents.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down
2 changes: 1 addition & 1 deletion Blueprint41/Core/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public static TValue GetValue<TKey, TValue>(this Dictionary<TKey, TValue> dictio
{
if (dictionary.TryGetValue(key, out TValue value))
return value;

return defaultValue;
}
public static TValue GetValue<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default!)
Expand Down
1,793 changes: 1,256 additions & 537 deletions Blueprint41/DatastoreTemplates/Domain_Data_Entity.cs

Large diffs are not rendered by default.

210 changes: 190 additions & 20 deletions Blueprint41/DatastoreTemplates/Domain_Data_Entity.tt

Large diffs are not rendered by default.

822 changes: 744 additions & 78 deletions Blueprint41/DatastoreTemplates/Domain_Data_Entity_Abstract.cs

Large diffs are not rendered by default.

117 changes: 115 additions & 2 deletions Blueprint41/DatastoreTemplates/Domain_Data_Entity_Abstract.tt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ if (DALModel.IsAbstract)
string <#= DALModel.NodeTypeName #> { get; }
<#
}
#>

#region Properties
<#
foreach (Property attr in DALModel.Properties)
{
if (attr.PropertyType == PropertyType.Collection || attr.IsNodeType)
Expand All @@ -115,12 +118,122 @@ if (DALModel.IsAbstract)
{
#>
<#= attr.OuterReturnType #> Get<#= attr.Name #>(DateTime moment);
void Set<#= attr.Name #>(<#= attr.OuterReturnType #> value, DateTime? moment);
//void Set<#= attr.Name #>(<#= attr.OuterReturnType #> value, DateTime? moment);
<#
}
}
}
#>

#endregion

#region Relationship Properties
<#
foreach (var attr in DALModel.GetPropertiesOfBaseTypesAndSelf().Where(property => property.PropertyType != PropertyType.Attribute))
{
if (attr.PropertyType == PropertyType.Collection)
{
if (!attr.Relationship.IsTimeDependent)
{
/*******************************************************************************************
*** ***
*** NORMAL COLLECTION ***
*** ***
*******************************************************************************************/
#>

#region <#= attr.Name #> (Collection)

List<<#= attr.Relationship.Name #>> <#= attr.Name.ToSingular() #>Relations();
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(Func<<#= attr.Relationship.Name #>.Alias, QueryCondition> expression);
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(Func<<#= attr.Relationship.Name #>.Alias, QueryCondition[]> expression);
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(<#= attr.Relationship.Properties.ToJsonNotation() #>);
void Add<#= attr.Name.ToSingular() #>(<#= attr.ForeignEntity.ClassName #> <#= attr.ForeignEntity.Name.ToCamelCase() #><#= attr.Relationship.Properties.ToJsonNotation(attr.Relationship, true) #>);
void Remove<#= attr.Name.ToSingular() #>(<#= attr.ForeignEntity.ClassName #> <#= attr.ForeignEntity.Name.ToCamelCase() #>);

#endregion
<#
}
else
{
/*******************************************************************************************
*** ***
*** TIME DEPENDENT COLLECTION ***
*** ***
*******************************************************************************************/
#>

#region <#= attr.Name #> (Time Dependent Collection)

List<<#= attr.Relationship.Name #>> <#= attr.Name.ToSingular() #>Relations();
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(Func<<#= attr.Relationship.Name #>.Alias, QueryCondition> expression);
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(Func<<#= attr.Relationship.Name #>.Alias, QueryCondition[]> expression);
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(JsNotation<DateTime?> Moment = default<#= attr.Relationship.Properties.ToJsonNotation(attr.Relationship, true, true) #>);
void Add<#= attr.Name.ToSingular() #>(<#= attr.ForeignEntity.ClassName #> <#= attr.ForeignEntity.Name.ToCamelCase() #>, DateTime? moment<#= attr.Relationship.Properties.ToJsonNotation(attr.Relationship, true) #>);
void Remove<#= attr.Name.ToSingular() #>(<#= attr.ForeignEntity.ClassName #> <#= attr.ForeignEntity.Name.ToCamelCase() #>, DateTime? moment);

#endregion
<#
}
}
else if (attr.PropertyType == PropertyType.Lookup)
{
if (!attr.Relationship.IsTimeDependent)
{
/*******************************************************************************************
*** ***
*** NORMAL LOOKUP ***
*** ***
*******************************************************************************************/
#>

#region <#= attr.Name #> (Lookup)

<#= attr.Relationship.Name #> <#= attr.Name #>Relation();
<#= attr.Relationship.Name #> Get<#= attr.Name #>If(Func<<#= attr.Relationship.Name #>.Alias, QueryCondition> expression);
<#= attr.Relationship.Name #> Get<#= attr.Name #>If(Func<<#= attr.Relationship.Name #>.Alias, QueryCondition[]> expression);
<#= attr.Relationship.Name #> Get<#= attr.Name #>If(<#= attr.Relationship.Properties.ToJsonNotation() #>);
void Set<#= attr.Name #>(<#= attr.ForeignEntity.ClassName #> <#= attr.ForeignEntity.Name.ToCamelCase() #><#= attr.Relationship.Properties.ToJsonNotation(attr.Relationship, true) #>);

#endregion
<#
}
else
{
/*******************************************************************************************
*** ***
*** TIME DEPENDENT LOOKUP ***
*** ***
*******************************************************************************************/
#>

#region <#= attr.Name #> (Time Dependent Lookup)

<#= attr.Relationship.Name #> <#= attr.Name #>Relation(DateTime? moment = null);
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Relations();
<#= attr.Relationship.Name #> Get<#= attr.Name #>If(DateTime? moment, Func<<#= attr.Relationship.Name #>.Alias, QueryCondition> expression);
<#= attr.Relationship.Name #> Get<#= attr.Name #>If(DateTime? moment, Func<<#= attr.Relationship.Name #>.Alias, QueryCondition[]> expression);
<#= attr.Relationship.Name #> Get<#= attr.Name #>If(DateTime? moment<#= attr.Relationship.Properties.ToJsonNotation(attr.Relationship, true, true) #>);
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(Func<<#= attr.Relationship.Name #>.Alias, QueryCondition> expression);
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(Func<<#= attr.Relationship.Name #>.Alias, QueryCondition[]> expression);
List<<#= attr.Relationship.Name #>> <#= attr.Name #>Where(JsNotation<DateTime?> Moment = default<#= attr.Relationship.Properties.ToJsonNotation(attr.Relationship, true, true) #>);
void Set<#= attr.Name #>(<#= attr.ForeignEntity.ClassName #> <#= attr.ForeignEntity.Name.ToCamelCase() #>, DateTime? moment<#= attr.Relationship.Properties.ToJsonNotation(attr.Relationship, true) #>);

#endregion
<#
}
}
}

/*******************************************************************************************
*** ***
*** END RELATIONSHIP PROPERTIES ***
*** ***
*******************************************************************************************/
#>
#endregion

<#
if (!string.IsNullOrEmpty(DALModel.UnidentifiedProperties))
{
#>
Expand Down Expand Up @@ -248,7 +361,7 @@ if (DALModel.IsAbstract)
foreach (Property attr in inherited.Properties)
{
#>
public Property <#= attr.Name #> { get; } = <#= Datastore.GetType().FullName.Replace("+", ".") #>.Model.Entities["<#= inherited.Name #>"].Properties["<#= attr.Name #>"];
public EntityProperty <#= attr.Name #> { get; } = <#= Datastore.GetType().FullName.Replace("+", ".") #>.Model.Entities["<#= inherited.Name #>"].Properties["<#= attr.Name #>"];
<#
}
#>
Expand Down
Loading

0 comments on commit ae5f71e

Please sign in to comment.