Windows Phone 中的 SQL 查询表达式

本文关键字:查询表 表达式 查询 SQL Phone 中的 Windows | 更新日期: 2023-09-27 17:56:26

>我有一个数据库 - ScoreDB 和表 - 带有属性名称和分数的分数表。我想按降序显示分数:

t = from ScoreTable s in scoreDB.ScoreTable
                    orderby s.Score descending
                    select s;

行错误:

GameScoreCollection = new ObservableCollection<ScoreTable>(t);

«成员'BrainGainWP.ScoreTable.Score'不支持SQL的翻译。但是,如果顺序名称都有效:

t = from ScoreTable s in scoreDB.ScoreTable
                    orderby s.Name descending
                    select s;

表代码:

[Table]
public class ScoreTable : INotifyPropertyChanged, INotifyPropertyChanging
{       
    [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
  }
    private string _Name;
    [Column]
    public string Name
    {
        get
        {
            return _Name;
        }
        set
        {
            if (_Name != value)
            {
                NotifyPropertyChanging("Name");
                _Name = value;
                NotifyPropertyChanged("Name");
            }
        }
    }
    [Column]
    private int  _Score;
    public int  Score
    {
        get
        {
            return _Score;
        }
        set
        {
            if (_Score != value)
            {
                NotifyPropertyChanging("Score");
                _Score = value;
                NotifyPropertyChanged("Score");
            }
        }
    }

Windows Phone 中的 SQL 查询表达式

[Column]在你的私有变量Score上,而不是在公共变量上:

private int  _Score;
[Column]
public int  Score
{
    get
    {
        return _Score;
    }
    set
    {
        if (_Score != value)
        {
            NotifyPropertyChanging("Score");
            _Score = value;
            NotifyPropertyChanged("Score");
        }
    }
}