Reputation: 2788
I want to use sql in cluase in linq for that i have tried contains but its showing error. My Code is..
var allId = new int[] { 31, 32, 33 };
var libraryList = from c in db.COURSELIBRARies
join cc in db.COURSECATEGORYTAGGINGs on c.LIBITEMID equals cc.COURSEID
where allId.Contains(cc.CATEGORYID) // here error is showing.
select new Library { Id = c.LIBITEMID, Name = c.GROUPNAME, Desc = c.DESCRIPTION, logo = c.LOGO, CategoryId = cc.CATEGORYID };
Error is :
'int[]' does not contain a definition for 'Contains' and the best extension method overload
'System.Linq.Queryable.Contains<TSource>(System.Linq.IQueryable<TSource>, TSource)'
has some invalid argumentsInstance argument: cannot convert from
'int[]'
to'System.Linq.IQueryable<int?>'
Upvotes: 1
Views: 1411
Reputation: 6132
Have you included;
using System.Linq;
?
Another possible cause would be that the value you are passing into Contains() is not an INT. Try casting it: where allId.Contains((int)cc.CATEGORYID)
Upvotes: 1