Developer forum

Forum » Development » Code first item inherit

Code first item inherit

Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

I'm trying to use code first item creation, but cant get the inheritance working.

   [Item(Name = "Paragraph", Description = "Root paragraph, in which all other paragraphs inherit settings from.")]
    [Category("Example")]
    [Icon(Dynamicweb.Core.UI.Icons.KnownIcon.Dashboard)]
    [TitleField("Title")]
    [AreaRule,
        StructureRule(StructureContextType.Paragraphs),
        ChildRule(false)]
    public class Paragraph : ItemEntry
    {
        [Group("General")]
        public string Title { get; set; }
    }

[Item(Name = "Default Paragraph", Description = "Standard paragraph for all purpose use.")]
    [Category("Example")]
    [Icon(Dynamicweb.Core.UI.Icons.KnownIcon.Dashboard)]
    [TitleField("Title")]
    [AreaRule,
        StructureRule(StructureContextType.Paragraphs),
        ChildRule(false)]
    [ModuleAttachmentRule(true)]
    public class DefaultParagraph : Paragraph
    {
        [Group("General")]
        [RichText]
        public string Content { get; set; }
    }

This result in two items in the same folder, and DefaultParagraph is not inheriting Paragraph, what am I missing?


Replies

 
Nicolai Pedersen
Reply

I am not sure we support this. I'll forward this to a more competent Item developer!

BR Nicolai

 
Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

Thanks. I can now see that it actually inherits the fields, but I thought it was going to appear below the other item, as it does if you use the admin interface to create inherited items.

 
Vladimir
Reply
This post has been marked as an answer

Hi Martin,

Yes, it works, though not the same way as in interface.
It would be nice to implement it the same, and I think we will do it eventually.

Best regards,

Vladimir

 

PS registered a task 37676 "Add the default page view attribute for code first items"

Votes for this answer: 1

 

You must be logged in to post in the forum