The following class works with a memory database, but when I do a build against a postgres database I get the following error: Literal type 'NNet.Model.Common.Web.HTMLLink+ContentType' is not supported. If I remove the ContentType default, then I get the same message for LocationType.

   [HierarchyRoot(InheritanceSchema = InheritanceSchema.SingleTable)]
    public class HTMLLink : NNetEntity {

        /// <summary> Type of page at end of link </summary>
        public enum ContentType {
            /// <summary> link to a review page (mainly for services) </summary>
            Review,
            /// <summary> link to an information page</summary>
            Information,    // link to an information page
            /// <summary> link to an article</summary>
            Article,
            /// <summary> link to an Award</summary>
            Award,
        };

        /// <summary> Location of page </summary>
        public enum LocationType {
            Internal,       // Link to an internal neighbournet page, used until ages imported
            External        // Link to external page
        };

        [Field]
        public string URL { get; set; }
        [Field]
        public DateTime Published { get; set; }
        /// <summary> Type of page at end of link </summary>
        [Field(DefaultValue = ContentType.Article)]
        public ContentType Content { get; set; }
        /// <summary> Location of page </summary>
        [Field(DefaultValue = LocationType.Internal)]
        public LocationType Location { get; set; }

        public HTMLLink() { }

    }

asked Jul 18 '11 at 17:28

Tony's gravatar image

Tony
53262628

Hello Tony,

Is there any necessity in making the enums nested? Try moving them out from HTMLLink class. This should work.

(Jul 19 '11 at 04:17) Dmitri Maximov Dmitri%20Maximov's gravatar image

Ok, will try that, but only as a work around. However I perfer to encapsulate the enums in the class they apply to, so outside of HTMLLink they are HTMLLink.ContentType, and dont conflict. I would rather initialise the fields in a constructor that move the enums out of the class. It seems strange it works with a memory database?

(Jul 19 '11 at 04:57) Tony Tony's gravatar image

Tony,

There are no transformations applied to the objects while working with memory storage, so they are added (stored) as is. However, when dealing with real persistent storage we have to find the appropriate column type for every persistent field. Ordinary enums (not nested) are supported for ages but it seems that there is a bug with nested ones, so we have to work this out.

Thanks for pointing us to the issue.

(Jul 19 '11 at 05:02) Dmitri Maximov Dmitri%20Maximov's gravatar image

Moving them out of the class did not work, got "Literal type 'NNet.Model.Common.Web.ContentType' is not supported." instead.

(Jul 19 '11 at 14:55) Tony Tony's gravatar image

Tony, my fault. I didn't read the issue properly and was thinking we were talking about using enums as persistent fields.

Actually, the question is about using FieldAttribute with DefaultValue property set to a member of enum. And according to the results, this case is not supported at all. Will be fixed.

Sorry for my lack of attention.

(Jul 19 '11 at 17:21) Dmitri Maximov Dmitri%20Maximov's gravatar image

One Answer:

The issue is fixed. For more information, see the announcement.

answered Jul 31 '11 at 11:04

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

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

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×5
×2

Asked: Jul 18 '11 at 17:28

Seen: 5,665 times

Last updated: Jul 31 '11 at 11:04

powered by OSQA