NTEXT与SQL Server CE中超过4000个字符中的Windows Phone [英] NTEXT with more than 4000 characters in SQL Server CE in Windows Phone

查看:250
本文介绍了NTEXT与SQL Server CE中超过4000个字符中的Windows Phone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

NTEXT with more than 4000 characters in SQL Server CE in windows phone

我有一个数据库,在我的Windows Phone应用程序使用 NTEXT 在一个表中的字段,我试着写一些内容到这一领域,但我得到一个出现InvalidOperationException 的消息:

I have a database in my windows phone app with a ntext field in one of the tables, I'm trying to write some content to this field, but I get an InvalidOperationException with the message:

字符串截断:最大= 4000,LEN = 4621

String truncation: max=4000, len=4621

我试图用 NTEXT ,因为我知道,为nvarchar 不接受超过4000个字符。

I am trying to use ntext because I know that nvarchar doesn't accept more than 4000 chars.

我搜索了一个解决方案,但我找不到任何。

I've searched for a solution but I couldn't find any.

我发现我做不到唯一的解决办法在Windows上使用手机,因为它使用了的SqlConnection 的SqlCommand SqlDbType

The only solution I found I cannot use on windows phone, because it uses the SqlConnection and SqlCommand with SqlDbType.

下面是列的声明方式:

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



我与它插入

I'm inserting it with:

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



有谁知道有什么解决方法吗?

Does anyone know any workaround?

感谢您事先的答案!

推荐答案

我觉得你在实际的数据库文件列不NTEXT,无论出于何种原因。

I think your column in the actual database file is not ntext, for whatever reason.

这对我来说工作得很好:

This works fine for me:

    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");                
        }
    }



列声明:

Column declaration:

[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();
                }
            }
        }

这篇关于NTEXT与SQL Server CE中超过4000个字符中的Windows Phone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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