direct access to foreign key

5 posts, 0 answers
  1. Ratndeep
    Ratndeep avatar
    40 posts
    Member since:
    Feb 2009

    Posted 03 Dec 2009 Link to this post

    Could anyone twll me please How to Make direct access to foreign key fields of persistent classes in Telerik open Access 2009 Q3 release?

  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 04 Dec 2009 Link to this post

    Hello Ratndeep,

    In Q3 release of OpenAccess, the reverse mapping wizard creates the foreign key fields by default. If you already have a persistent model created with a previous version of OpenAccess, I would suggest you to do the mapping again, from the beginning. That means deleting your current persistent classes and configuration, and generating them again with the Reverse Mapping Wizard.

    Greetings,
    Zoran
    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. Ratndeep
    Ratndeep avatar
    40 posts
    Member since:
    Feb 2009

    Posted 04 Dec 2009 Link to this post

    Thanks for your reply Zoran but i am following forward mapping not reverse.
  5. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 04 Dec 2009 Link to this post

    Hi Ratndeep,

    I am not sure exactly what you mean by "direct access", but for example in the Order-Orderline sample, you can define a field on the OrderLine class which is an int (or whatever you use as primary key type) that will hold the reference back to the parent (the Order class).
    When using the forward mapping wizard on the Order class you will see this new field as the "reverse field" in your 1:m relationship (when you don't do the field, all you have there is [Auto], meaning the you can not navigate from the child to the parent)

    EDIT:
    The int type I wrote above is  not correct. Ofcause it has to be of type Order (the parent). Must have been to busy writing blogs :-) Sorry

    Regards

    Henrik
  6. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 04 Dec 2009 Link to this post

    Hello Ratndeep,

    Indeed Henrik is right. You just have to make sure that the foreign key property (for example the customID field of the Order class) and the reference property (the Customer property of the Order class) map to the same column in the data base. In the Order example this will be the CustomerID column of the Orders table.
    This will produce an xml mapping like bellow (after using the forward mapping wizard):
    <class name="Order">
                ...
                 
                <field name="customerID">
                  <extension key="db-column" value="mssql">
                    <extension key="db-type" value="CHAR" />
                    <extension key="db-column-name" value="CustomerID " />
                    <extension key="db-sql-type" value="varchar" />
                    <extension key="db-length" value="255" />
                  </extension>
                </field>
                <field name="customer">
                  <extension key="db-column" value="mssql">
                    <extension key="db-type" value="CHAR" />
                    <extension key="db-column-name" value="CustomerID " />
                    <extension key="db-sql-type" value="varchar" />
                    <extension key="db-length" value="255" />
                  </extension>
                </field>
                 
                ...
    </class>

    I hope this helps.

    Kind regards,
    Jordan
    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.
Back to Top
DevCraft banner