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

SQL Server and Oracle backends

2 Answers 68 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Peter Szintai
Top achievements
Rank 1
Peter Szintai asked on 12 Sep 2013, 09:27 AM
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 Answers, 1 is accepted

Sort by
0
Ralph Waldenmaier
Telerik team
answered on 12 Sep 2013, 11:46 AM
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.
0
Peter Szintai
Top achievements
Rank 1
answered on 12 Sep 2013, 12:10 PM
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
Tags
Databases and Data Types
Asked by
Peter Szintai
Top achievements
Rank 1
Answers by
Ralph Waldenmaier
Telerik team
Peter Szintai
Top achievements
Rank 1
Share this question
or