Hi @mc
I can do it using
standardIds[0]but how to do it usingstandardIds? standardIds is List<int>();
If the standardIds is a List<int>(), the standardIds[0] is an int type. Since the int does not contain a definition of "Contains" and "Length", it will throw a compilation error directly. Like this:
So, please check the standardIds again. it might not a List<int>().
You can refer to the following code:
List<int> standardIds = new List<int>() { 101, 102 };
var result = (from q in _dbcontext.Product
group q by q.SkuId into g
where g.Count(x => standardIds.Contains(x.StandardId)) == standardIds.Count
select g.Key).ToList();
var standardidarray =new int[]{ 101, 102};
var items = new List<int[]>() { standardidarray };
var result2 = (from q in _dbcontext.Product
group q by q.SkuId into g
where g.Count(x => items[0].Contains(x.StandardId)) == items[0].Length
select g.Key).ToList();
The output as below:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion