Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow fields of type EntitySet<T> in a Structure #156

Open
ondrejtucny opened this issue Jul 22, 2021 · 1 comment
Open

Allow fields of type EntitySet<T> in a Structure #156

ondrejtucny opened this issue Jul 22, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@ondrejtucny
Copy link

ondrejtucny commented Jul 22, 2021

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

@alex-kulakov
Copy link
Contributor

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 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

@alex-kulakov alex-kulakov added the enhancement New feature or request label Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants