我在执行以下查询时遇到错误
错误: 指定的LINQ表达式包含对与不同上下文关联的查询的引用
查询:
var wordlePuzzle = (from wp in wordlepostitionRepository.All
join wtc in wordletextclueRepository.All on wp.WordleTexCluetId equals wtc.WordleTextClueId
join w in wordleRepository.All on wtc.WordleId equals w.WordleId
where wtc.WordleId == id
select new WordlePuzzle
{
Row = w.WordleRow,
Column = w.WordleColumn,
Title = w.WordleTitle,
DifficultyLevel = DifficultyLevel.Easy,
Duration = w.WordleDuration,
ExpiresOn = w.ExpireDate
});
我尝试在查询结束后附加.AsEnumerable();
,但仍然发出错误。
我所有这些表只有一个数据库。
答案 0 :(得分:2)
查看实现工作单元模式,以便您可以跨存储库共享上下文实例。