1

DB - ScoreDB とテーブル - プロパティ Name と Score を持つ ScoreTable があります。スコアを降順で表示したい:

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

1 に答える 1

4

パブリック変数ではなく[Column]、プライベート変数を使用しています。Score

private int  _Score;
[Column]
public int  Score
{
    get
    {
        return _Score;
    }
    set
    {
        if (_Score != value)
        {
            NotifyPropertyChanging("Score");
            _Score = value;
            NotifyPropertyChanged("Score");
        }
    }
}
于 2013-01-27T19:04:43.407 に答える