gpt4 book ai didi

c# - Windows Phone 中 SQL Server CE 中超过 4000 个字符的 NTEXT

转载 作者:行者123 更新时间:2023-12-02 05:38:16 25 4
gpt4 key购买 nike

Windows Phone 中SQL Server CE 中超过4000 个字符的NTEXT

我的 Windows Phone 应用程序中有一个数据库,其中一个表中有一个 ntext 字段,我试图向该字段写入一些内容,但我得到一个 InvalidOperationException 消息:

String truncation: max=4000, len=4621

我正在尝试使用 ntext,因为我知道 nvarchar 不接受超过 4000 个字符。

我已经搜索了解决方案,但找不到。

我发现我无法在 Windows Phone 上使用的唯一解决方案,因为它使用 SqlConnectionSqlCommand 以及 SqlDbType

列的声明方式如下:

    private string _content;
[Column(DbType="ntext")]
public string Content
{
get
{
return _content;
}
set
{
if (value != _content)
{
_content = value;
NotifyChange(o => o.Content);
}
}
}

我正在插入它:

cn.Articles.InsertAllOnSubmit(articlesToSave); 
cn.SubmitChanges();

有人知道解决方法吗?

提前感谢您的回答!!

最佳答案

我认为您在实际数据库文件中的列不是 ntext,无论出于何种原因。

这对我来说很好:

    using (NorthwindContext ctx = new NorthwindContext(NorthwindContext.ConnectionString))
{
ctx.DeleteDatabase();
ctx.CreateDatabase();
var category = new Categories();
category.CategoryName = "Test";
category.Description = new string('x', 6666);
ctx.Categories.InsertOnSubmit(category);
ctx.SubmitChanges();

var testCat = ctx.Categories.First();
if (testCat.Description.Length == 6666)
{
MessageBox.Show("Works on my Windows Phone");
}
}

列声明:

[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Description", DbType="NText", UpdateCheck=UpdateCheck.Never)]
public string Description
{
get
{
return this._Description;
}
set
{
if ((this._Description != value))
{
this.OnDescriptionChanging(value);
this.SendPropertyChanging();
this._Description = value;
this.SendPropertyChanged("Description");
this.OnDescriptionChanged();
}
}
}

关于c# - Windows Phone 中 SQL Server CE 中超过 4000 个字符的 NTEXT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11365186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com