目前在做一个.net maui软件 其中一个页面想实现一个时间线效果 并将实体类 diary 数据 依照时间字段 CreaTime 进行绑定 进行展示 时间线组件采用 blazor 中的 timeline 组件 现需要将 diary 数据获取并 new 到timeline 中的 timelineitem 类中 应该如何在 .cs 文件中实现
diary实体类
public class Diary{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
public string Content { get; set; }
public DateTime CreaTime { get; set; } = DateTime.Now;
}
获取所有数据项 GetAllDiaries
public async Task<IEnumerable<Diary>> GetAllDiariesAsync(
Expression<Func<Diary, bool>> where, int skip, int take) =>
await Connection.Table<Diary>().Where(where).Skip(skip).Take(take)
.ToListAsync();
TimelineItem 类定义 示例
private readonly TimelineItem[] AlertTimelineItems =
[
new()
{
Content = "Create a service