在窗口电话7中更新sql Ce

时间:2011-12-20 08:19:04

标签: c# windows-phone-7

在项目i用户SQL CE中,我有表:

[Table]
public class Article : INotifyPropertyChanged, INotifyPropertyChanging
{

    // Define _cid: private field, public property, and database column.
    private int _aid;

    [Column(DbType = "INT NOT NULL IDENTITY", IsDbGenerated = true, IsPrimaryKey = true)]
    public int aid
    {
        get { return _aid; }
        set
        {
            NotifyPropertyChanging("aid");
            _aid = value;
            NotifyPropertyChanged("aid");
        }
    }

    // Define nameColor name: private field, public property, and database column.
    private int _rid;

    [Column]
    public int rid
    {
        get { return _rid; }
        set
        {
            NotifyPropertyChanging("rid");
            _rid = value;
            NotifyPropertyChanged("rid");
        }
    }


    private string _title;
    [Column]
    public string title
    {
        get { return _title; }
        set
        {
            NotifyPropertyChanging("title");
            _title = value;
            NotifyPropertyChanged("title");
        }
    }


    private string _thumnail;
    [Column]
    public string thumnail
    {
        get { return _thumnail; }
        set
        {
            NotifyPropertyChanging("thumnail");
            _thumnail = value;
            NotifyPropertyChanged("thumnail");
        }
    }

    private string _DesScription;
    [Column(DbType = "NTEXT")]
    public string DesScription
    {
        get { return _DesScription; }
        set
        {
            NotifyPropertyChanging("DesScription");
            _DesScription = value;
            NotifyPropertyChanged("DesScription");
        }
    }

    private int _orderID;
    [Column]
    public int orderID
    {
        get { return _orderID; }
        set
        {
            NotifyPropertyChanging("orderID");
            _orderID = value;
            NotifyPropertyChanged("orderID");
        }
    }

    private string _pubDate;
    [Column]
    public string pubDate
    {
        get { return _pubDate; }
        set
        {
            NotifyPropertyChanging("pubDate");
            _pubDate = value;
            NotifyPropertyChanged("pubDate");
        }
    }

    private string _linkURL;
    [Column]
    public string linkURL
    {
        get { return _linkURL; }
        set
        {
            NotifyPropertyChanging("linkURL");
            _linkURL = value;
            NotifyPropertyChanged("linkURL");
        }
    }
    #region INotifyPropertyChanged Members

    public event PropertyChangedEventHandler PropertyChanged;

    // Used to notify that a property changed
    private void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    #endregion

    #region INotifyPropertyChanging Members

    public event PropertyChangingEventHandler PropertyChanging;

    // Used to notify that a property is about to change
    private void NotifyPropertyChanging(string propertyName)
    {
        if (PropertyChanging != null)
        {
            PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
        }
    }

    #endregion
}

当我更新Colum Thumnail时,我有错误:

SQL Server无法处理NText,Text,Xml或Image数据类型的比较

因为特殊字符插入数据库插入序列trogn我应该使用BbType =“NTEXT”

请帮助我!

1 个答案:

答案 0 :(得分:6)

您可以通过向此列添加[Column(UpdateCheck = UpdateCheck.Never)]来删除此列以进行并发检查。

请参阅此博文关于Linq to sql并发检查:http://blogs.msdn.com/b/matt/archive/2008/05/22/into-to-linq-to-sql-optimistic-concurrency.aspx