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

Reverse Mapping with a 1:1 relationship

3 Answers 111 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
George
Top achievements
Rank 1
George asked on 05 Jun 2009, 06:26 PM
Perhaps I'm missing something, but I don't understand why the following happens.  I will 'try' to keep it simple.

I have two tables:

Customer
CustomerAddress

In Customer, is a field named BillToAddressID, which contains the ID of the address in the CustomerAddress table.

I perform a reverse mapping against the tables.

Everything works great, except for one thing...

There are other addresses in CustomerAddress, and the user may want to change the Bill To Address to something that already exists in the CustomerAddress table.

However, this is a problem, because apparently, when you have a one to one relationship with a table (or one to many for that matter), the ID field in the Customer Table (in this case BillToAddressID), is not included in the class that is generated.

Can someone tell me why?

I add it back in manually, so when a user wants to change the address, all that needs to be updated is the BillToAddressID in the Customer Table (if it exists in CustomerAddress, of course).

My question is, why does reverse mapping remove the field?  I completely understand that you don't need it, if you are creating a new customer, and also creating a new Bill To Address, but you are stuck if you want to change that value to another address that exists in the CustomerAddress table.

Maybe I'm just off my nut, and if I am, can someone please set me straight?

Thanks, Kuba

3 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 08 Jun 2009, 05:59 AM
Hi Kuba Cole,

OpenAccess currently provides an object reference to the related field e.g. CustomerAdress in your case. You can access it's Id using Customer.CustomerAddress.Id. In order to set this Id field directly though, there is currently a workaround for direct access to foreign key fields. It is discussed in the following KB article. I must notice though that this workaround is only temporary and this process will be automated and the functionality usable via wizards in one of our next, post Q2 releases.

I hope the workaround works for you. If you require any additional clarifications, we are looking forward for your future feedback.

All the best,
Zoran
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
George
Top achievements
Rank 1
answered on 08 Jun 2009, 08:07 PM
Zoran,

   Thanks for the reply.  We had actually already implented what the workaround suggested to get by (we weren't sure however, if the changes would cause other problems... it seems that it doesn't).  I'm glad to see that the option will be available in the future.  It is particularly annoying for us at the moment as we are in the first stages of development on a new project.  As such, changes to the database are rather frequent.  It gets pretty tedious having to add that stuff back in manually.

Thanks again...

Kuba
0
Zoran
Telerik team
answered on 10 Jun 2009, 05:09 AM
Hello Kuba Cole,

Yes, we admit that it is not very convenient to do these manual changes to the generated code. That is way we are doing our best to have the proper code generated as soon as possible. We will notify you when we have the functionality, even if it is before a major release.

Regards,
Zoran
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Design Time (Visual Designer & Tools)
Asked by
George
Top achievements
Rank 1
Answers by
Zoran
Telerik team
George
Top achievements
Rank 1
Share this question
or