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

Custom mappings

2 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.
Cameron
Top achievements
Rank 1
Cameron asked on 26 May 2014, 02:24 PM
Hi there,

So I have an existing database with a strange table in it. It has 114 columns and one of those columns is a row type column. Depending on what that column is set to determines how the rest of the columns are or aren't used. So If the type is set to 5, then we use column 1,2,3,20, and 60.... the rest are ignored. I have 50 some types that all use a "random" assortment of the possible columns. Any columns that aren't used are set to null.

I would like to map this table 50 times and make 50 sane objects based on this table. The idea is to remove all of the columns that I don't need for a particular "type" and rename the columns I do need into something meaningful. I am not the owner of this database (merely a consumer) so I can't not refactor this table. I can't rename its columns or break it into pieces or anything of the sort. I have to just "deal" with what is already there. I can not create views in this database either.

 I have been playing around with OpenAccess and I just can't seem to make this happen. Could some one point me in the right direction on how to make this happen? Link to an article or basically just anything to get me going would be great.

Thanks

-Cam 

2 Answers, 1 is accepted

Sort by
0
Cameron
Top achievements
Rank 1
answered on 26 May 2014, 08:44 PM
So I brought the crazy table into the modeling surface (using update from database) then I created a few (as a test/starting point) domain classes and explicitly mapped them to the crazy table. Saved. Compiled. Everything looks fine but at run time it blows up with a:

Using a duplicate table name attempted for table 'crazy table' of class 'cool domain class'.

So I am guessing this isn't allowed...
0
Boris Georgiev
Telerik team
answered on 28 May 2014, 11:48 AM
Hi Cameron,

Unfortunately this is not supported by Telerik Data Access. You can map one or more tables to one class, but you cannot map one table to more than one class. The only workaround is to use a Flat Inheritance, but it also needs a specific column in the table which is mapped to the base class. But as I understand the database is legacy and you will not be able to create a new column, so in your case, the only workaround is not applicable.

If there is anything else for which we can help, do not hesitate to contact us again.

Regards,
Boris Georgiev
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
General Discussions
Asked by
Cameron
Top achievements
Rank 1
Answers by
Cameron
Top achievements
Rank 1
Boris Georgiev
Telerik team
Share this question
or