Will be great, if fields in structure can inherit configuration from outer field


public sealed class TextedLink<TEntity> : Structure where TEntity : Entity
    // Always not null
    [Field(Nullable = false)]
    public string Caption { get; set; }

    // May be null
    [Field(Nullable = true)]
    public string Description { get; set; }

    // Can be null or not depend on outer FieldAttribute
    [Field(NullableInherited = true)]
    public TEntity Link { get; set; }


public partial class TestEntity : Entity
    [Field(Nullable = false)]
    public string Name { get; set; }

    // Link can't be null
    [Field(Nullable = false)]
    public TextedLink<TestEntity> NotNullStructure { get; set; }

    // Link can be null
    public TextedLink<TestEntity> NullStructure { get; set; }

Important moment, when 'Nullable = false', SQL should use INNER JOIN, otherwise use LEFT JOIN

Query.All<testentity>().Where(e => e.NotNullStructure.Link.Name == "test").Count(); // INNER JOIN

Query.All<testentity>().Where(e => e.NullStructure.Link.Name == "test").Count(); // LEFT JOIN

As I know, it's default behavior for link fields

asked Oct 25 '16 at 09:15

Anton%20Guschin's gravatar image

Anton Guschin

Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA