我有一些简单的类,看起来像这样:
Class Favorites
Guid UserId
Guid ObjectId
Class Objects
Guid Id
String Name
使用Entity Framework,我希望选择所有被用户标记为收藏的对象。
所以我尝试了以下代码:
context.Objects.Where(
x => x.Id ==
context.Favorite.Where(f => f.UserId == UserId)
.Select(f => f.ObjectId).Any()
);
但我不明白。我也尝试了intersect,但据我理解它必须是相同的类型。一个用户可以有多个收藏对象。