1

When I attempt to run the following query against Raven DB, I get a "Expression type not supported: System.Linq.Expressions.TypedParameterExpression" exception.

        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();

Can I make a query like this work somehow?

Thanks, Matt

mattcole
  • 1,229
  • 2
  • 12
  • 22
  • The second query is the one that fails, right? Also, what is the type if k.GivingUserId? – Esteban Elverdin Sep 27 '13 at 15:19
  • Wouldn't you need to pull out the user id from the first query, not the user name? Also, you could build a static index using `LoadDocument` which would allow you to make one query instead of two. – Matt Johnson-Pint Sep 27 '13 at 15:54

1 Answers1

1

You can try

    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();

You need to add using Raven.Client.Linq for allowing the In<string>

Esteban Elverdin
  • 3,552
  • 1
  • 17
  • 21