0
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 customerUserIds 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>

1 Answer 1

2

Try ToList() instead of ToArray() in the first query. It will return a List<int> that contains the "Contains" method

List<int> ids = query;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.