SQL Server and Oracle backends

3 posts, 0 answers
  1. Peter Szintai
    Peter Szintai avatar
    28 posts
    Member since:
    Jul 2009

    Posted 12 Sep 2013 Link to this post

    Hi All!

    First of all, before I started this thread, I looked for similar threads of course:

    Our applicaton should run on SQL Server and Oracle backend (but one client uses only one backend at a time).

    The physical database models are generated by a 3rd party tool, we tried to avoid the database dependent things: we don't use triggers, sp's, based on the"Mapping a Simple field" documentation we tried to find the similar data types (e.g.: DateTime in SQL and Date in Oracle, bigint in SQL and number(19,0) in Oracle etc.). Both databases contain the same table and column names, PK's, FK's etc.

    Our domain model is reverse engineered from the SQL Server database.
    The MetaDataContainer is loaded with the metadataSource = AttributesMetadataSource.FromAssembly(...) and metadataContainer = metadataSource.GetModel() methods.

    When I try to run the application on Oracle, it throws an exception:
    The metadata for field '<column>' of class '<class>' cannot be initialized: Type converter initialization failed. The converter with name 'OracleUdt2StringConverter' does not convert from CLR type 'System.Int64' to SQL type 'bigint'

    The reason is obvious: in the Oracle database the integers are stored in number column types, not in bigint.

    Based on the previsous forum threads, I think, a solution can be: reverse engineering the Oracle database into a differenct project (into a different namespace maybe?, same or different .rlinq name?), and in the code I have to load this metadatasource/metadatacontainer in the case of Oracle backend?

    For me it is enough, if somebody could say a simple 'Yes', if this is the best solution in our case, but I'm open to read any better suggestion!

    Regards,
    Peter Szintai
  2. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 12 Sep 2013 Link to this post

    Hi Peter,

    What you can do when you open the database with your container is to replace the stored SqlServer sql types with the respective oracle types. See this link for details on the OnDatabaseOpen method
    Here you have the MetadataContainer and also the information about the currently used backend. You can access the necessary tables and their columns and adjust them to fit your needs. With this approach you just need to have one model.

    I hope this information is helpful for you. 
    Do come back in case you have any other question.

    Regards,
    Ralph Waldenmaier
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  3. DevCraft banner
  4. Peter Szintai
    Peter Szintai avatar
    28 posts
    Member since:
    Jul 2009

    Posted 12 Sep 2013 Link to this post

    Hi Ralph!

    In fact, I tried this yesterday, and I can say, it works at the moment!
    (I modify the SqlType property in runtime, but I thought, it is a kind of "hacking", and I have to play with the different domain models.)

    Thank you!

    Peter Szintai
Back to Top