Can a persistent class be an inner class?

5 posts, 1 answers
  1. Peter
    Peter avatar
    23 posts
    Member since:
    Sep 2008

    Posted 24 Nov 2009 Link to this post

    Hi

    We're implementing a persistent audit trail that has an 'audit' class alongside each domain (business) class.  I'd like to make the audit class an inner class of the domain one, but I can't find a way to set up the OpenAccess (mapping) configuration for an inner class (using the namespace and class elements).  Is it possible?  (Not a problem if it isn't).

    Thanks, Peter
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 25 Nov 2009 Link to this post

    Hello Peter,

    I am afraid this is not fully supported by the wizards but there is a chance to get it working by editing the mapping configuration manually. Could you please tell us which approach you are using - forward or reverse mapping, so we can test if it is possible and provide you with the steps to achieve it?

    Regards,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Peter
    Peter avatar
    23 posts
    Member since:
    Sep 2008

    Posted 25 Nov 2009 Link to this post

    Hello Alexander

    We're using forward mapping (actually we generate the mapping configuration - and the persistent classes etc -  from our domain specific language), so no problem with manually setting up the configuration.

    Regards, Peter
  5. Answer
    Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 25 Nov 2009 Link to this post

    Hi Peter,

    I tested this scenario and it seems to be working fine. The configuration of the nested class is done the same way as the configuration of the outer class. The tricky part though is that in the mapping the name of the nested class is set by concatenating the two class names with a plus (+) sign. For example, if you have ClassA and ClassB (ClassB is nested in ClassA), the mapping would look like this:
    <mapping id="mssqlMapping">
        <namespace name="ConsoleApplication1">
          <class name="ClassA+ClassB">
            <extension key="db-table-name" value="ClassB" />
            <!-- manually added -->
            <field name="text">
              <extension key="db-column">
                <extension key="db-column-name" value="Text" />
              </extension>
            </field>
            <!-- end -->
          </class>
          <class name="ClassA">
            <extension key="db-table-name" value="ClassA" />
            <field name="number">
              <extension key="db-column">
                <extension key="db-column-name" value="Number" />
              </extension>
            </field>
          </class>
        </namespace>
    </mapping>

    The limitation is that the settings for ClassB are not available in the Forward mapping wizard and should be manually added. Please find my test project attached and let us know if you face any difficulties.

    Sincerely yours,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Peter
    Peter avatar
    23 posts
    Member since:
    Sep 2008

    Posted 25 Nov 2009 Link to this post

    Thank you Alexander - the '+' bit was what I was missing (I couldn't find it the documentation, so you might want to add it for the next update).

    Regards, Peter
Back to Top
DevCraft banner