Natalija

Natalija

  • 2.1k
  • 21
  • 1.9k

convert SQL to LINQ

Jun 16 2015 4:27 AM
Hi, All.
I have SQL-request:
 
select FullName, CreatedBy, CreatedOn, DomainName, ModifiedBy from SystemUser
where SystemUserId In (
SELECT SystemUserId
FROM [UserSettings]
where [TimeZoneBias] != -60
and [TimeZoneCode] != 110)
and IsDisabled = 0
 
I need to convert this request into LINQ.
I wrote this (this is my first LINQ-request):
from s in SystemUserSet
where s.SystemUserId.Contains
(from sy in UserSettingsSet
where sy.TimeZoneBias != -60 && sy.TimeZoneCode != 110
select sy.SystemUserId)
&& s.IsDisabled = 0
select s
 
 And I get error:
 
'System.Guid?' 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 arguments
Instance argument: cannot convert from 'System.Guid?' to 'System.Linq.IQueryable<System.Linq.IQueryable<System.Guid?>>'
 
 
 Please, could you help with convert?
Thanks!
 
 
 

Answers (22)