I have a basic dictionary like Dictionary<int,int>
, and want to compare it with my dbset on where clause.I tried something as in bellow,but I could not knock it off.I used Tuple<int,int>
instead of dictionary,it throws exception "Only primitive types or enumeration types are supported in this context."
public IEnumerable<Tuple<string,string,decimal>> CrossSellingCheck(Dictionary<int,int> idS)
if (idS.Count == 0) return null;
var temp = db.CrossSellings //these lines
.Where(m => idS.Any(a=> a.Key==m.MainProductId && a.Value==m.MainProductQuantity)); //these lines
if (temp.Any()) return null;
return db.Products.Include(i => i.productimagelist)
.Where(p => temp.Select(m => m.SubProductId).Contains(p.ProductId)).AsEnumerable()
.Select(item => new Tuple<string, string, decimal>(
item.productimagelist.First().ThumbUrl,
item.Name,
temp.Single(z => z.SubProductId == item.ProductId).DiscountRate)));