public JsonResult SearchUser(string term_, int[] assetOwnerIdList_)
{
term_ = term_.Trim();
var userMatches = (from user in _db.Query<User>()
where user.Name.Contains(term_) || user.Email.Contains(term_)
select new ItemLabelId { Label = user.Email, Id = user.UserId }).ToList().Any();
return Json(userMatches, JsonRequestBehavior.AllowGet);
}
So here is my code, I want to filter the result, if the user UserId is in the assetOwnerIdList_
list then remove them eg Result.RemoveAll.Where(user.UserId in assetOwnerIdList_)
Simple:
Result.RemoveAll(x => assetOwnerIdList_.Contains(x.UserId));
If you want to filter useMatches directly in your query, then:
This will only work if you query provider supports the contains method (IN Translation), otherwise, use the method above.
var userMatches = (from user in _db.Query<User>()
where user.Name.Contains(term_) || user.Email.Contains(term_)
&& assetOwnerIdList_.Contains(user.UserId) == false
select new ItemLabelId { Label = user.Email, Id = user.UserId }).ToList().Any();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With