NTEXT在ServiceStack.OrmLite [英] ntext in ServiceStack.OrmLite

查看:215
本文介绍了NTEXT在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆