1

DB のブール値を変更するクエリを取得しました。

    private void optFavorit_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
    {
        var opt_query = (from q in db.TableBarcode where q.IdBarcode == selectedItem select q).First();
        Database.Barcode currentBarcode = new Database.Barcode();

        if (opt_query.Favorit == true) 
        {
            currentBarcode.Update(selectedItem, false, opt_query.Scanned, opt_query.Titel, opt_query.Inhalt);
            optFavorit.Content = "Fav. adden";
        }
        else if (opt_query.Favorit == false)
        {
            currentBarcode.Update(selectedItem, true, opt_query.Scanned, opt_query.Titel, opt_query.Inhalt);
            optFavorit.Content = "Fav. entf."; 
        }
    }

クエリを実行した XAML ページを除いて、他のすべてのページで正しい結果が表示および更新されます。また、クエリを実行したページに戻ると、値を再度変更することはできません。

メモリに問題があるようです。完全なアプリを再起動すると、クエリを実行したページにも正しい結果が表示されますが、オブジェクトごとに 1 回しかクエリを実行できず、ここから再びループに巻き込まれます。

何か案が?助けていただければ幸いです。


編集:

大きな違いが何であるかを理解していなくても、解決策を見つけました。

        private void optFavorit_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
    {
        // Komischer weise sind 2 Abfragen nötig! Nicht opt_query.Favorit im if verwenden!
        var opt_query = (from q in db.TableBarcode where q.IdBarcode == selectedItem select q).First();
        var isFavo = (from q in db.TableBarcode where q.IdBarcode == selectedItem select q.Favorit).First();
        Database.Barcode currentBarcode = new Database.Barcode();

        if (isFavo == true) 
        {
            currentBarcode.Update(selectedItem, false, opt_query.Scanned, opt_query.Titel, opt_query.Inhalt);
        }
        else if (isFavo == false)
        {
            currentBarcode.Update(selectedItem, true, opt_query.Scanned, opt_query.Titel, opt_query.Inhalt);
        }
    }

たぶん誰かが私を説明できるかもしれませんが、少なくとも今はうまくいきます:)

4

0 に答える 0