0

Доброго времени суток! Подскажите как решить проблему: есть БД scoreDB, в ней таблица ScoreTable со свойствами Name (string) и Score (int). Хочу отобразить Score, упорядочив по возрастанию: t = from ScoreTable s in scoreDB.ScoreTable orderby s.Score descending select s;

На строке: GameScoreCollection = new ObservableCollection<ScoreTable>(t);

Компилятор возвращает: «The member 'BrainGainWP.ScoreTable.Score' has no supported translation to SQL.» (GameScoreCollection коллекция, к которой привязываю textBlock)

Если упорядочить по Name все работает: 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 int _Score;
    public int Score
    {
        get
        {
            return _Score;
        }
        set
        {
            if (_Score!= value)
            {
                NotifyPropertyChanging("Score");
                _Score= value;
                NotifyPropertyChanged("Score");
            }
        }
    }

    private string _Name;

    [Column]
    public string Name
    {
        get
        {
            return _Name;
        }
        set
        {
            if (_Name != value)
            {
                NotifyPropertyChanging("Name");
                _Name = value;
                NotifyPropertyChanged("Name");
            }
        }
    }

1 ответ 1

1

Нашел ответ:

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

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.