c# - LINQ: select specific value in a datatable column
问题描述
In table I have 4 Columns GroupName, Display, Value and ID How can I just show a specific data in display. I only want to show some of the groupNames Data for example I only want to show Groupname = company and display = Forbes
Here's my linq
sample = (from c in smsDashboardDBContext.CodeDefinitions
orderby c.Display ascending
select new CodeDefinitionDTO
{
GroupName = c.GroupName,
Display = c.Display,
Value = c.Value,
Id = c.Id
}).ToList();
解决方案
您可以where
在查询中添加语句。
where c.GroupName == "company" && c.Display == "Forbes"
推荐阅读
- sql - 具有 auto_increment 的两列
- php - 有没有办法在不使用 Imagick 和其他库的情况下检查 .gif 图像是否透明?
- bash - 按名称递归查找所有文件,使用shell脚本解密并重命名它们
- regex - $regex 查找整个单词,mongodb
- angular - 如何为Angular 8找到具有特定值的对象数量
- php - php 处理 & 作为 URL 中字符串的一部分
- wordpress - Apple Pay with Stripe - Wordpress 安装验证 - GCP
- javascript - 将 Javascript 文件与 wordpress 插件链接
- python - 在 python/kivy 中使用 screenmananger 时出现黑屏
- c# - 第三方项目未使用的自发布包中的build文件夹文件