1

当我尝试对 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();

我可以以某种方式进行这样的查询吗?

谢谢,马特

4

1 回答 1

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>

于 2013-09-27T15:34:59.653 回答