I'm trying to convert this sql statement to linq and need some assistance:
SELECT *
FROM userlocation ul
INNER JOIN wins_user w
ON ul.locationname = w.location
WHERE ul.locationname = 'Value'
OR ( NOT EXISTS(SELECT *
FROM mulitcustomeraccess
WHERE userid = 'Value') )
Here is my Linq code (usr is WINS_USER table):
billcodelist = String.Join(
",",
dc.USERLOCATIONs
.Where(f => f.LOCATIONNAME == usr.LOCATION ||
dc.MULITCUSTOMERACCESSes
.Where(d => d.USERID == usr.Name)
.Select(d => d.LOCATIONNAME)
.Contains(f.LOCATIONNAME))
.Select(f => f.BILLCODECUSTNUMLIST)
.ToArray());
I tried updating my linq code to this
billcodelist = String.Join(
",",
dc.USERLOCATIONs
.Where(f => f.LOCATIONNAME == usr.LOCATION ||
!dc.MULITCUSTOMERACCESSes
.Any(d => d.USERID == usr.Name)
.Select(d => d.LOCATIONNAME)
.Contains(f.LOCATIONNAME))
.Select(f => f.BILLCODECUSTNUMLIST)
.ToArray());
But then I get the following error :
'bool' does not contain a definition for 'Select' and no accessible extension method 'Select' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?) error.
My question is how do I convert that SQL to linq, what am I doing incorrectly?