如何在 SQLite-net-plc 中使用 Xamarin.Forms 中的“.OrderBy”?

How to use ".OrderBy" in Xamarin.Forms with SQLite-net-plc?

我想对我保存在 SQLite 数据库中的日历条目进行排序,以便在列表视图中显示它们。如何使用 SQLite-net-plc 订购它们?

我以为我可以写:.OrderBy<CalendarEntryStartDate> 但它不起作用,我尝试使用 SQLite 命令,但我在使用它们时遇到了一些麻烦,因为我对 m.db.

using System;
using SQLite;

namespace Stundenplan.Models
{
    public class CalendarEntry
    {
        [PrimaryKey, AutoIncrement]
        public int CalendarEntryId { get; set; }
        public string CalendarEntryTitle { get; set; }
        public string CalendarEntryDescription { get; set; }
        [Column("StatDate")]
        public DateTime CalendarEntryStartDate { get; set; }
        public DateTime CalendarEntryEndDate { get; set; }
        public TimeSpan CalendarEntrySpan { get; set; }
        public string CalendarEntryParticipants { get; set; }
        public string CalendarEntrytLocation { get; set; }
        public Boolean CalendarEntryPrivate { get; set; }
        public string CalendarEntryTags { get; set; }
        public string CalendarEntryColorTag { get; set; }
    }
}


using SQLite;
using System.Collections.Generic;
using Stundenplan.Models;
using System.Threading.Tasks;

namespace Stundenplan.Data
{
    public class CalendarEntryDatabase
    {
        readonly SQLiteAsyncConnection calendarentrydatabase;

        public CalendarEntryDatabase(string dbPath)
        {
            calendarentrydatabase = new SQLiteAsyncConnection(dbPath);
            calendarentrydatabase.CreateTableAsync<CalendarEntry>().Wait();
        }
        public Task<List<CalendarEntry>> GetCalendarEntrysAsync()
        {
            return calendarentrydatabase.Table<CalendarEntry>().ToListAsync();
        }
        public Task<CalendarEntry> GetCalendarEntryAsync(int id)
        {
            return calendarentrydatabase.Table<CalendarEntry>().Where(i => i.CalendarEntryId == id).FirstOrDefaultAsync();
        }
        public Task<int> SaveCalendarEntryAsync(CalendarEntry calendarentry)
        {
            if (calendarentry.CalendarEntryId == 0)
            {
                return calendarentrydatabase.InsertAsync(calendarentry);
            }
            else
            {
                return calendarentrydatabase.UpdateAsync(calendarentry);
            }
        }
        public Task<int> DeleteCalendarEntryAsync(CalendarEntry calendarentry)
        {
            return calendarentrydatabase.DeleteAsync(calendarentry);
        }
        public Task<List<CalendarEntry>> GetCalendarEntriesOrderedByStartDateAsync()
        {
            return calendarentrydatabase.Table<CalendarEntry>().OrderBy<>;
        }
    }
}

我收到错误

CS0103: The name "CalendarEntryStartDate" does not exist in the current context;

CS0305: The Usage of the method group "OrderBy"(generic) need 1-Typeargumetns.

我做错了什么?

OrderBy 需要一个 lambda 表达式作为参数

OrderBy(x => x.CalendarEntryStartDate)