1

I have pass a Query using ImongoQuery as userInfoDataQuery in the below method. but i don't know how to filter this query in a collection.

public IQueryable<UserInfo> UserInfoDataByQuery(IMongoQuery userInfoDataQuery)
{
    if (ServerIsDown) return null;
    UserInfoList.Clear();
    **var filter = Builders<UserInfo>.Filter.And(userInfoDataQuery);** //getting Error in this Line
    var userData = db.UserInfo.Find( filter).ToList();
    if (userData.Count() > 0)
    {
        foreach (UserInfo item in userData)
        {
            UserInfoList.Add(item);
        }
    }
    var result = UserInfoList.AsQueryable();
    return result;
}

How to pass the Filter as IMongoQuery in order to provide dynamic filter for a method?

Neeraj Mehta
  • 1,675
  • 2
  • 22
  • 45

1 Answers1

0

Wouldn't this work? as Query object takes IMongoQuery as a parameter.

  var filter = Query.And(userInfoDataQuery);
KaSh
  • 175
  • 1
  • 11