Custom mappings

3 posts, 0 answers
  1. Cameron
    Cameron avatar
    2 posts
    Member since:
    May 2014

    Posted 26 May 2014 Link to this post

    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.


  2. Cameron
    Cameron avatar
    2 posts
    Member since:
    May 2014

    Posted 26 May 2014 in reply to Cameron Link to this post

    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...
  3. DevCraft banner
  4. Boris Georgiev
    Boris Georgiev avatar
    190 posts

    Posted 28 May 2014 Link to this post

    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.

    Boris Georgiev
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Back to Top