SQLServer rlinq and Oracle

9 posts, 0 answers
  1. Rui
    Rui avatar
    30 posts
    Member since:
    Feb 2012

    Posted 10 Apr 2012 Link to this post

    I must have different schemas (rlinq) for different DBMS?
    Can't use the same for SQLServer and for Oracle?
  2. Rui
    Rui avatar
    30 posts
    Member since:
    Feb 2012

    Posted 11 Apr 2012 Link to this post

    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?
  3. DevCraft banner
  4. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 12 Apr 2012 Link to this post

    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 >>
  5. rd
    rd avatar
    20 posts
    Member since:
    Jun 2007

    Posted 16 Apr 2012 Link to this post

    .
  6. Rui
    Rui avatar
    30 posts
    Member since:
    Feb 2012

    Posted 17 Apr 2012 Link to this post

    Hello Zoran,
    that seems nice. 
    But I'm using designer, I will loose the changes or not?
  7. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 19 Apr 2012 Link to this post

    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.
  8. Murilo
    Murilo avatar
    17 posts
    Member since:
    Jul 2012

    Posted 07 Jan 2013 Link to this post

    Is the above solution still the better one for this case? Thanks
  9. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 10 Jan 2013 Link to this post

    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.
  10. Murilo
    Murilo avatar
    17 posts
    Member since:
    Jul 2012

    Posted 10 Jan 2013 Link to this post

    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

    :)
Back to Top
DevCraft banner