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
53●26●26●28
Hello Tony,
Is there any necessity in making the enums nested? Try moving them out from
HTMLLink
class. This should work.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?
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.
Moving them out of the class did not work, got "Literal type 'NNet.Model.Common.Web.ContentType' is not supported." instead.
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
withDefaultValue
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.