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

One to one association issues

0 Answers 37 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dilshod
Top achievements
Rank 1
Dilshod asked on 16 Dec 2016, 05:52 AM

Hello,

In my model I was using one to many associations until recently  and now decided to use one to one associations. Once I added a one to one relationship between two tables it builds fine, but when I run it, it throws exception: Exception thrown: 'System.InvalidCastException' in Telerik.OpenAccess.Runtime.dll
Additional information: Unable to cast object of type 'Model.Entities.SAPassport' to type 'OpenAccessRuntime.common.OID'.

I will try to explain my model here. I have a Student entity and it has many other one to many associations. I recently added a new entity called Passport and relationship between student and passport is one to one(Both of their PrimaryKey fields have the same value because of one to one relationship). In my code I am creating a Passport and Student. Both of their Id fields has the same value. But when I save I get the exception above.

Then I tried with really simple entities. I created Person entity and PersonInfo and made a one to one relationship between them. There are no more associations to these entities or from these entities. When I create these entities and set their IDs as the same and save I don't get any exceptions.

My question is, why there is an exception in the first use case? And what does that exception mean? There is no documentation about it.

 

Thanks,

Dilshod Niyozov

Tags
Development (API, general questions)
Asked by
Dilshod
Top achievements
Rank 1
Share this question
or