当我尝试针对Raven DB运行以下查询时,我得到“不支持表达式类型:System.Linq.Expressions.TypedParameterExpression”异常。
var userIdsICareAbout = Session.Query<User>()
.Where(u => u.Username == username
|| u.Managers.Any(m => m == username))
.Select(u => u.Username)
.ToList();
var kudos = Session.Query<Kudo>()
.Where(k => userIdsICareAbout.Any(u => u == k.GivingUserId)
|| userIdsICareAbout.Any(u => u == k.ReceivingUserId))
.ToList();
我可以以某种方式进行这样的查询吗?
谢谢, 马特
答案 0 :(得分:1)
你可以尝试
var userIdsICareAbout = Session.Query<User>()
.Where(u => u.Username == username
|| u.Managers.Any(m => m == username))
.Select(u => u.Username)
.ToList();
var kudos = Session.Query<Kudo>()
.Where(k => k.GivingUserId.In<string>(userIdsICareAbout)
|| k.ReceivingUserId.In<string>(userIdsICareAbout)
.ToList();
您需要添加using Raven.Client.Linq
才能允许In<string>