c# - 如何使用 LINQ 将表值与对象列表的属性值进行比较?
问题描述
鉴于这些课程,
public class Foo
{
...
public IList<Bar> BarList{ get; set; }
}
public class Bar
{
...
public int Property{ get; set; }
}
当 Property 是列表中对象的属性时,如何使用 LINQ 创建一个查询来过滤 Property 值的匹配项?
即,我想返回OtherTable 的Property 列的值与Foo.BarList 中存在的任何Property 值匹配的所有记录。就像是
var result = db.MainTable.Include(m => m.OtherTable.Where(o => o.Property == {{Foo.BarList.Property}}) ...rest of query
谢谢你。
解决方案
推荐阅读
- c# - 类型不能作为非托管结构封送
- java - Google AdMob 没有在我的应用程序上显示任何广告印象?
- assembly - 8086 中通用寄存器的区别:[bx] 有效,[cx] 无效?
- javascript - 如何强制 iframe 视频在 Android 设备上旋转到横向模式?
- javascript - Extjs 构建无法解决依赖 Ext.app.Application
- git - PhpStorm 版本控制窗口显示“本地更改”中未更改的文件
- kotlin - “在构造函数中泄漏'this'”警告应该适用于最终类和开放类?
- r - 从数据框列中查找索引或唯一值
- wordpress - 获取具有不同分类术语的帖子的分类术语
- tmux - 在附加到会话之前在 tmux 中显示消息