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

SQLServer rlinq and Oracle

8 Answers 93 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.
Rui
Top achievements
Rank 1
Rui asked on 10 Apr 2012, 04:45 PM
I must have different schemas (rlinq) for different DBMS?
Can't use the same for SQLServer and for Oracle?

8 Answers, 1 is accepted

Sort by
0
Rui
Top achievements
Rank 1
answered on 11 Apr 2012, 06:50 PM
in Fluent when you have a Boolean column in SQLServer you have "bit" and in Oracle "Number" (or something like it).

But when we are making the fluent code we should be able to specify something like HasColumn(Types.Boolean) or HasColumn(typeof(bool)) .
What you say?
0
Zoran
Telerik team
answered on 12 Apr 2012, 11:19 AM
Hello Rui,

 At the moment, there is partial support for multiple database servers if you use .rlinq or fluent. If you would like your model to work equally well for both database servers, you should skip the specification of the SQL type for the columns. For example if you map a property with fluent code like this:

configuration.HasProperty(x => x.IsActive).HasFieldName("_isActive").ToColumn("IsActive").IsNotNullable().HasColumnType("bit");

I would suggest you to use mapping like the following:
configuration.HasProperty(x => x.IsActive).HasFieldName("_isActive").ToColumn("IsActive").IsNotNullable();

So the mapping in the first example defines a property that is mapped to a "IsActive" column which is of type bit, which is specific for MS Sql Server. However, in the second example, there is no type specified for the column. In this case, OpenAccess will automatically create the column in your MS Sql Server database with the bit type and if you try to use the same model against Oracle, the appropriate NUMBER type will be used there. The OpenAccess runtime has the capabilities to dynamically decide what is the most appropriate type of a column based on the relational database server. However that functionality works only in the case where no specific mapping is specified by the user.Greetings,
Zoran
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
0
rd
Top achievements
Rank 1
answered on 16 Apr 2012, 05:13 PM
.
0
Rui
Top achievements
Rank 1
answered on 17 Apr 2012, 09:53 AM
Hello Zoran,
that seems nice. 
But I'm using designer, I will loose the changes or not?
0
Zoran
Telerik team
answered on 19 Apr 2012, 05:35 PM
Hi Rui,

 Unfortunately, if you use the designer, you can apply multiple backend scenario only in the case where you have no schema defined and leave for OpenAccess to create it for you during runtime. If you already have a MsSQL server schema, reverse mapped in an .rlinq file(I suppose you do, since you have your column definitions generated), you are limited to using only your current backend  out-of-the-box.
What you can do, is to copy the Fluent Generated Code in a separate file, and then switch Fluent Code Generation off. Then you can edit that file without having it overridden when you save the .rlinq file. Otherwise, as you assumed, your code will be overridden when code re-generation takes place.

Kind regards,
Zoran
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the OpenAccess ORM, subscribe to their blog feed now.
0
Murilo
Top achievements
Rank 1
answered on 07 Jan 2013, 06:46 PM
Is the above solution still the better one for this case? Thanks
0
Alexander
Telerik team
answered on 10 Jan 2013, 08:45 AM
Hello Murilo,

Yes, for the moment this is still the valid approach for this case.

All the best,
Alexander
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Murilo
Top achievements
Rank 1
answered on 10 Jan 2013, 12:06 PM
Thanks Alexander,

Do you know if we can edit the fluent metada generation template? 

Is there any article or help related to this?

Thanks :)

Edit:

Nevermind, I got it to work. If someone else needs:

1) Open the following file: FluentMapping.ttinclude (located under Telerik\OpenAccess ORM\dsl2010\CodeGenerationTemplates\CSharp\Includes)
2) Comment these lines:
//hasColumnTypeToken = this.GetHasColumnTypeToken(column.SqlType);
//hasPrecisionToken = this.GetHasPrecisionToken(primitiveMember);
//hasScaleToken = this.GetHasScaleToken(primitiveMember);
3) Save file
4) Create a root folder named 'OpenAccessTemplates' in your openaccess project and paste the file you edited
5) I also pasted a file named 'FluentMappingCS.tt' but I don't know if this one is necessary, I didn't edit anything in this one

:)
Tags
Databases and Data Types
Asked by
Rui
Top achievements
Rank 1
Answers by
Rui
Top achievements
Rank 1
Zoran
Telerik team
rd
Top achievements
Rank 1
Murilo
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or