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

NVarchar Mapping

3 Answers 104 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Herbert
Top achievements
Rank 1
Herbert asked on 13 Aug 2012, 12:38 PM
Hi,

I have a mapped class with some string properties. Fluent mapping always results in a schema with "varchar" columns for SQL server.
The documentation states that it is possible to specify "nvarchar" columns as default using the app.config/web.config.

However for my current project I won't be able to use an app.config file.
I've tried to create a default mapping to "nvarchar" in code, but this failed:

protected override MetadataContainer CreateModel()
{
    MetadataContainer container = base.CreateModel();
    container.DefaultMapping.NullForeignKey = true;
    container.NameGenerator.UseModelNames = true;
    container.DefaultMapping.ClrMap.Add(new DefaultTypeMapping()
    {
        ClrType = typeof(String).Name,
        SqlType = "nvarchar",
        AdoType = OpenAccessType.Varchar
    });
    return container;
}

So what I'm asking for: how can I create such a default type mapping in code ?

Thank you

Herbert

3 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 15 Aug 2012, 02:15 PM
Hi Herbert,

 The approach you are trying to apply is an internal representation of the type mapping which is not recommended to be explicitly changed by the user at this stage. We will improve that API and provide capabilities for better manipulation of the default type mapping.

We have however, provided a way to map your string fields via Fluent API to nvarchar instead of varchar (and the respective types according to the type of backend used). You should apply the approach described in this help article, or more precisely, you need to use the IsUnicode() method described there.

All the best,
Zoran
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
0
Herbert
Top achievements
Rank 1
answered on 15 Aug 2012, 06:51 PM
Hi Zoran,

I've seen that this feature is on the roadmap but not yet in the actual assembly (at least not in the free version).
When can we expect the new release ?

Thank you for your great support.

Herbert
0
Ivailo
Telerik team
answered on 20 Aug 2012, 11:02 AM
Hi Herbert,

While the Visual Designer part of this functionality is not yet released, in our latest official build (Service pack 2) you can find the Fluent API enhancements that would allow you to define your mapping in a backend-independent way. 

You can give it a try and we are looking forward to any feedback you can share with us, so that we can consider any possible improvements for the Q3 release.


All the best,
Ivailo
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Tags
Data Access Free Edition
Asked by
Herbert
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Herbert
Top achievements
Rank 1
Ivailo
Telerik team
Share this question
or