NTEXT在ServiceStack.OrmLite [英] ntext in ServiceStack.OrmLite
问题描述
如何能在ServiceStack.OrmLite代码n文字的数据类型第一?
how can i have nText datatype in ServiceStack.OrmLite Code first ?
public class Email
{
[AutoIncrement]
public long ID { get; set; }
public DateTime Date { get; set; }
public string From { get; set; }
public string Subject { get; set; }
nText =>
public string Body { get; set; }
}
如果我使用的字符串数据类型,ormlite产生NVARCHAR(8000 )数据库
if i use string datatype , ormlite generate nVarchar(8000) in database
我需要的数据超过8000字
i need more than 8000 character for data
推荐答案
你需要转换你的机身
键入字节[]
从字符串
为ServiceStack.OrmLite使用 VARCHAR(最大)
列类型。类似下面的:
You need to convert your Body
type to byte[]
from string
for ServiceStack.OrmLite to use the varchar(max)
column type. Something like the below:
public byte[] Body { get; set; }
这样做的原因在于该ServiceStack.OrmLite代码中。
The reason for this lies within the ServiceStack.OrmLite code.
在文件 ServiceStack.OrmLite / OrmLiteDialectProviderBase.cs ,该方法在 InitColumnTypeMap()
是:
DbTypeMap.Set<byte[]>(DbType.Binary, BlobColumnDefinition);
在文件中的ServiceStack.OrmLite.SqlServer/SqlServerOrmLiteDialectProvider.cs 的,方法 SqlServerOrmLiteDialectProvider()在
是:
In the file ServiceStack.OrmLite.SqlServer/SqlServerOrmLiteDialectProvider.cs, under the method SqlServerOrmLiteDialectProvider()
is:
base.BlobColumnDefinition = "VARBINARY(MAX)";
从这个代码,你可以看到一个内部映射正在发生从C#类型内部。ServiceStack.OrmLite类型,然后再返回到SqlServer的类型
From this code, you can see that an internal mapping is taking place from the C# type to the internal ServiceStack.OrmLite type and then back out to the SqlServer type.
这问题解释如何来回转换字符串和字节数组之间的.NET字符串到字节数组C#。
This question explains how to convert back and forth between strings and byte arrays, .NET String to byte Array C#.
这篇关于NTEXT在ServiceStack.OrmLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!