可以使用Join操作符将Intention和OrderItem两个实体类进行连接查询,然后在Where子句中添加筛选条件即可,代码如下:

var result = dbContext.Intention.Join(
                orderItems,
                intention => new { intention.GoodsId, intention.ActivityType },
                orderItem => new { orderItem.GoodsId, orderItem.ActivityType },
                (intention, orderItem) => intention
            ).ToList();

上述代码中,Join操作符将Intention和OrderItem两个实体类连接起来,连接条件为Intention.GoodsId == OrderItem.GoodsId且Intention.ActivityType==OrderItem.ActivityType。在连接后的结果集中,我们只需要返回Intention实体类即可,因此在Select子句中只返回了intention。最后调用ToList方法将查询结果转换为List类型的集合


原文地址: https://www.cveoy.top/t/topic/fdve 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录