Reputation: 174
var query = _db.Mst_Users
.Where(item => item.CustomerUserId == customerUserId)
.Traverse(item => _db.Mst_Users.Where(parent => item.CustomerUserId == parent.ParentId))
.Select(item =>Convert.ToString(item.CustomerUserId)).ToArray();
In the above query I'm getting customerUserId
s in an array:
int[] ids = query;
From the above int array:
var getgroup = from item in _db.Mst_Group
where ids.Contains(item.CustomerUserId)
select item;
However, it shows the following error:
int[] does not contain a definition for Contains and the best extension method overload system.linq.iqueryable.contains<tsource>
Upvotes: 0
Views: 1903
Reputation: 39278
Try ToList() instead of ToArray() in the first query.
It will return a List<int>
that contains the "Contains" method
List<int> ids = query;
Upvotes: 2