Hi
I know I can [CustomField("NVARCHAR(255)")]
for unicode support in SQLServer, but it would be nice if there is an attribute I can use, for example the StringLength(255)
could be extended with StringLength(255, true)
Is this something you could add?
You can modify the StringConverter change all string types to use Unicode with:
StringConverter converter = OrmLiteConfig.DialectProvider.GetStringConverter();
converter.UseUnicode = true;
But OrmLite’s TypeConverters doesn’t support adhoc Unicode customizations at the property level, but you can implement a typed attribute to achieve the same effect, e.g:
public class StringColumnAttribute : CustomFieldAttribute
{
public StringColumnAttribute(int length, bool unicode)
: base(unicode ? "N":"" + $$"VARCHAR({length})") {}
}
public class Table
{
[StringColumn(length:255, unicode:true)]
public string Name { get; set; }
}
That’s a nice solution! Thanks!