在windows phone 7中更新sql Ce

本文关键字:更新 sql Ce windows phone | 更新日期: 2023-09-27 18:18:17

在项目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
}

当我更新列缩略图时,我有错误:

SQL Server不处理NText、Text、Xml和Image数据类型的比较

由于数据库插入序列中有特殊字符,我是否应该使用BbType = "NTEXT"

在windows phone 7中更新sql Ce

您可以通过在此列中添加[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