sqlite - 如何使用LINQ查询获取以大写,小写或组合形式保存的某些记录的计数

标签 sqlite xamarin.forms

我需要从IN / in / In获取SoccerStatus的计数,无论记录是用大写,小写还是Xamarin Forms中的SQLite数据库中的IN or in or In组合保存。我该如何实现?

enter image description here

var count_in = (from x in conn.Table<SoccerAvailability>().Where(x => x.SoccerStatus ==  IN) select 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();


编辑:根据您的评论,我看到您使用的Linq提供程序不支持string.Equals。您可以尝试以下方法,它们应该更便于携带,但可能会更慢...

var count_in = (from x in conn.Table<SoccerAvailability>().Where(x => x.SoccerStatus.ToUpper() == "IN") select x).Count();

关于sqlite - 如何使用LINQ查询获取以大写,小写或组合形式保存的某些记录的计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56123361/

相关文章:

Android:应用程序打包的数据库有多安全

gitignore 的 Git pull 问题

xamarin.forms - 使用youtube API编译测试项目xamarin表单时出错

xamarin.forms - Xamarin Forms Maps - 自定义 Pin 图像

c# - Xamarin 表单选取器中的 System.ArgumentOutOfRangeException

c# - MonoTouch : SQLite-net thread safety and SQLiteConfig. 序列化

javascript - 使用 Visual Studio 2015 在 Apache Cordova 中打开缺少 exec :SQLitePlugin.

objective-c - iOS 推出应用程序更新。在需要更新数据库时保持用户数据完整

xaml - Xamarin 执行 OnPlatform StaticResource 绑定(bind)的新方式

c# - Prism VM 与页面代码中的 View 绑定(bind)