Sqlite 如何使用LINQ查询获取以大写、小写或组合形式保存的特定记录的计数
我需要从Sqlite 如何使用LINQ查询获取以大写、小写或组合形式保存的特定记录的计数,sqlite,xamarin.forms,Sqlite,Xamarin.forms,我需要从SoccerStatus中获取IN/IN/IN的计数,无论记录是以大写、小写形式保存,还是以Xamarin表单的SQLite数据库中ieIN或IN或IN的组合保存。我怎样才能做到这一点 var count_in=(从conn.Table()中的x开始。其中(x=>x.SoccerStatus==in)选择x)。count(); 使用string.Equals并告诉它忽略大小写 var count_in = (from x in conn.Table<SoccerAvailabil
SoccerStatus
中获取IN/IN/IN
的计数,无论记录是以大写、小写形式保存,还是以Xamarin表单的SQLite数据库中ieIN或IN或IN的组合保存。我怎样才能做到这一点
var count_in=(从conn.Table()中的x开始。其中(x=>x.SoccerStatus==in)选择x)。count();
使用string.Equals并告诉它忽略大小写
var count_in = (from x in conn.Table<SoccerAvailability>().Where(x => string.Equals(x.SoccerStatus, "IN", StringComparison.OrdinalIgnoreCase)) select x).Count();
var count_in=(从conn.Table()中的x开始,其中(x=>string.Equals(x.SoccerStatus,“in”,StringComparison.OrdinalIgnoreCase))选择x.count();
编辑:根据您的评论,我发现您使用的Linq提供程序不支持string.Equals。您可以尝试以下方法,它应该更便携,但可能会慢一点
var count_in = (from x in conn.Table<SoccerAvailability>().Where(x => x.SoccerStatus.ToUpper() == "IN") select x).Count();
var count_in=(从conn.Table()中的x开始,其中(x=>x.SoccerStatus.ToUpper()==“in”)选择x.count();
将尝试此操作并回复shortly@dazedandconfused-现在我得到了数据库异常SQLite exception没有这样的函数等于
,你能帮我一下吗
var count_in = (from x in conn.Table<SoccerAvailability>().Where(x => x.SoccerStatus.ToUpper() == "IN") select x).Count();