【问题标题】:Consult records within the master detail from the master table Entity Framework Core从主表 Entity Framework Core 查询主详细信息中的记录
【发布时间】:2020-08-28 23:59:00
【问题描述】:

我需要从主表查询主明细中的记录。我有purchases 表和purchases detail 表,我需要咨询包含产品集合的购买。

模型参数:

public class PurchaseParmsDto
{       
    public ICollection<Int32> ProductsId { get; set; }
}

查询:

var query = (from p in _context.Purchase
             where p.DetailPurchase.Where(x => purchaseParms.ProductsId.Contains(x.IdProducto))
             select new...)

运行查询时出现此错误:

严重性代码描述项目文件行状态已删除
错误 CS0029 无法隐式转换类型'System.Collections.Generic.IEnumerable' en 'bool'
ApplicationComercio D:\Proyectos\AppComercioMultiApi\ApplicationComercio\Controllers\PurchasesController.cs 163 活动

你能帮帮我吗?谢谢

【问题讨论】:

标签: c# sql entity-framework entity-framework-core


【解决方案1】:

替换任何地方。

此查询允许您在主表的详细信息中搜索所有匹配的产品

var query = (
                    from p in _context.Purchase
                    where p.DetailPurchase.Any(x => purchaseParms.Products.Count==0|| purchaseParms.Products.Contains(x.IdProducto))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-30
    • 2012-04-30
    • 2021-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多