Allow fields of type EntitySet<T> in a Structure
Currently, associations are not supported in structures. Consider the following example showing how this could be useful:
[HierarchyRoot]
public class Config : Entity
{
[Field, Key]
public int Id { get; set; }
}
[HierarchyRoot]
public class Settings : Entity
{
[Field, Key]
public int Id { get; set; }
}
public class Tracker<T> : Structure
{
[Field, Association]
public EntitySet<T> History { get; set; }
[Field, Association]
public EntitySet<T> Current { get; set; }
[Field, Association]
public EntitySet<T> Future { get; set; }
}
[HierarchyRoot]
public class Container : Entity
{
[Field, Key]
public int Id { get; set;}
[Field]
public Tracker<Config> Configuration { get; set; }
[Field]
public Tracker<Setting> Settings { get; set; }
}
I am tracking the history of certain items within some container entity. These items are linked to the container via a set of associations, which determine whether it's a currently valid, future, or historical item. Further, I can have multiple unrelated types of items history-tracked this way within a single container entity. By using a Structure I am able to design a generic, reusable solution.
Currently, to achieve at least a partial reusability of the pattern, I have to use an interface instead of a Structure descendant, and use an explicit implementation in the container object, so that I am able to support multiple unrelated types of items, like in the example above. This is less convenient and misuses interface implementations where Structure-based composition would be more appropriate
Hello Ondrej,
We need to think of it and investigate possibilities because EntitySet is a complex structure which represents connection between tables unlike reference to another Entity which has actual column in tables. So EntitySet<T> requires an entity as owner. Structure has no such rule and that allows Structures to be instantiated outside entity. I guess it will be not so easy to "merry" them