gpt4 book ai didi

sqlite - SQLite.SQLiteException:没有这样的功能:在获取CurrentDate时使用LINQ查询来字符串化

转载 作者:行者123 更新时间:2023-12-03 18:32:27 25 4
gpt4 key购买 nike

我想从SQLite数据库中的SoccerAvailability中获得两列,例如SoccerStatus,SoccerDate到列表中,其中使用LINQ查询的SoccerDate =“ Today”?我已经尝试了以下查询,但是它抛出异常,我只需要CurrentDate,查询中就不需要时间。

List<SoccerAvailability> myList = (from x in conn.Table<SoccerAvailability>().Where(x => x.CurrentDate == DateTime.Now.ToString("ddMMyyyy")) select x).ToList();

未处理的异常:

SQLite.SQLiteException:没有此类函数:tostring

最佳答案

在执行查询之前将当前日期转换为字符串

var currentDate = DateTime.Now.ToString("ddMMyyyy");
List<SoccerAvailability> myList = (from x in conn.Table<SoccerAvailability>().Where(x => x.CurrentDate == currentDate) select x).ToList();

关于sqlite - SQLite.SQLiteException:没有这样的功能:在获取CurrentDate时使用LINQ查询来字符串化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55988614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com