EntitySpaces
EntitySpaces copied to clipboard
EntitySpaces Studio generates buggy code for references to other classes
Hi, this is the code generated by ES Studio for the Kunden property of my auftraege Class:
public Kunden Kunden
{
get
{
if (this._Kunden == null)
{
this._Kunden = new Kunden();
this._Kunden.es.Connection.Name = this.es.Connection.Name;
this.SetPreSave("Kunden", this._Kunden);
if(this._Kunden == null && FkKunden != null)
{
if (!this.es.IsLazyLoadDisabled)
{
this._Kunden.Query.Where(this._Kunden.Query.IdKunden == this.FkKunden);
this._Kunden.Query.Load();
}
}
}
return this._Kunden;
}
set
{
this.RemovePreSave("Kunden");
if(value == null)
{
this.FkKunden = null;
this._Kunden = null;
}
else
{
this.FkKunden = value.IdKunden;
this._Kunden = value;
this.SetPreSave("Kunden", this._Kunden);
}
}
}
The getter returns allways an empty Kunden class because of the if(this._Kunden == null && FkKunden != null)
check which is allways false because this._Kunden
is empty but not null. The check should be if (!this._Kunden.es.HasData && this.FkKunden != null)
to work properly.
BTW: This is a show stopper!
This issue can be solved by changing line 678 of Generated - Hierarchical (C#).est
from if(this._<%=objName%> == null<%
to if(!this._<%=objName%>.es.HasData<%
This is also part of my pull request #13