8 Answers, 1 is accepted
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?
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
that seems nice.
But I'm using designer, I will loose the changes or not?
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.
Zoran
the Telerik team
Yes, for the moment this is still the valid approach for this case.
All the best,
Alexander
the Telerik team
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
:)