November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
First of all, it is not required to extend the class to have attributes, but if you need a subclass for some other reason, then there is a way to solve this.
Simply make your class A behave as a Club class in the eyes of the framework. Meaning you will have to put attributes on the Club class for them to be available for class A. This will make ClubQuery work also.
There is a .Net attribute you will have to add to class A, with the name EntityTypeOverrideAttribute, like this:
[StarCommunity.Core.Modules.EntityTypeOverride(typeof(Club))] public class A : Club { }
Great! Didn't know about the EntityTypeOverride, it solved everything (altough I had to transfer data from attribut of class A to matching Club attribute).
The reason to extend Club was simply to handle attributes without having to know the attribute name all over the site, like a.Location instead of club.getAttributeValue<string>("attr_location")...
Anyway, thanks a lot - it saved my day :)
Is there any way to query custom attributes in an extended class?
I have extended the Club module to a new class A, with some extra attributes. When searching for A I use ClubQuery and gets the expected result - as long as I create queries with only Club attributes (Name, Description, etc.). BUT I now want to create a query with a custom attribute that only exists in the extension (A). Of course the following error occurs: "There is no attribute with the name 'attr_location' for the type 'StarCommunity.Modules.Club.Club'." Any ideas how to solve this?
Should I somehow create a custom AQuery, extending ClubQuery? How could I then force it to query type A? Or should I add the attribute to Club and somehow get/set custom attribute in base class of A?