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

Support for multiple associations on the same primitive member

3 Answers 43 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 17 Aug 2012, 08:43 AM

Hi

We are currently evaluating OpenAccess as an ORM to use in our projects and have come across the following issue.

We have a table called Security which has a large number of columns. We have split this table into three sql views (Security,SecurityCashFlow, SecurityCurrent). We have then mapped three entities one for each view. The following error occurs when trying to create the associations.


“The primitive member 'SecurityId' used in foreign key association 'SecurityHasSecurityCashflow' is used in another association 'SecurityHasSecurityCurrent'. This setup is not supported by the OpenAccess runtime.”

Security has a 0..1:1 association with both SecurityCashFlow and SecurityCurrent. The SecurityId field is the key for each of the entities.

Is it possible in Open Access to have multiple associations to the same property? or is there another way to support this scenario?

Thanks

Chris

3 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 17 Aug 2012, 02:36 PM
Hi Chris,

It is true that at the moment OpenAccess cannot handle more than one association based on the same foreign key member/column.

However, I think there is a good solution for your case which avoids this limitation. As the three views share the same id column, this means that the associations between the three views are 1:1 and one object always has the other two on the other side, there is no case of a null reference. Having this in mind, it should not make a difference if you define the associations the other way around, where SecurityCashFlow and SecurityCurrent have the foreign keys and Security holds the primary key. You would get the same SecurityCashFlow and SecurityCurrent references in the Security class.

So please just try dragging the associations in the opposite direction and let us know if you face further difficulties.

Greetings,
Alexander
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
0
Swee Eng
Top achievements
Rank 1
answered on 25 Oct 2012, 03:23 AM
Hi,

I am facing the same issue in my usage of OpenAccess. The thing is I do not have liberty to change the database as I like, as the database is from a third party. So as such, there is no way I can go around the problem? So I should forsake using OpenAccess? Hope you can advise me on this. Thanks.

Regards,
Swee Eng
0
Alexander
Telerik team
answered on 29 Oct 2012, 10:58 AM
Hello Swee Eng,

Could you share some information about your database schema? What type of associations are present there? Please describe the setup that you are not able to map with OpenAccess, so we can reproduce it locally and try to find a solution for you.

Regards,
Alexander
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Swee Eng
Top achievements
Rank 1
Share this question
or