This is a migrated thread and some comments may be shown as answers.

direct access to foreign key

4 Answers 97 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ratndeep
Top achievements
Rank 1
Ratndeep asked on 04 Dec 2009, 04:29 AM

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

4 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 04 Dec 2009, 07:54 AM
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.
0
Ratndeep
Top achievements
Rank 1
answered on 04 Dec 2009, 10:28 AM
Thanks for your reply Zoran but i am following forward mapping not reverse.
0
IT-Als
Top achievements
Rank 1
answered on 04 Dec 2009, 12:19 PM
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
0
Jordan
Telerik team
answered on 04 Dec 2009, 05:13 PM
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.
Tags
Getting Started
Asked by
Ratndeep
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Ratndeep
Top achievements
Rank 1
IT-Als
Top achievements
Rank 1
Jordan
Telerik team
Share this question
or