entity framework - linq to entities Not in statement -


I'm new to linq for organizations. I am trying to do this in a statement and when I run it, So I'm back to me. But if I run SQL equivalents then I get the data back.

The SQL statement I am trying to replicate

  SELECT * FROM [SCRAPREASON] WHERE [CODE] NOT <[CodeEDA]  

In order to select [CODE] [/ CODE]

this time I have a link

  var DefectCode = PumaOEEEntities ScrapReasons. Where (x => PumaOEEEntities.QualityAlertRules.Any (y = & gt; y.Code! = X.Code)). Select (x = & gt; new {GroupID = x.Code}). ToList (); Can anyone see what I'm doing?   

You should compare the code for equality (instead of == ! = ):

  var reasons = PumaOEEEntities.ScrapReasons. Where (x => PUMAITETExVivalAlitor Rule. Any (y = & gt; y.Code == x.Code)). Order By (x = & gt; x.Code). Ollist ();  

Generated will look like a SQL:

  SELECT [extent1]. [Code] AS [code], // other columns [DBO]. [ScrapReasons] AS [Extent1] where not present (SELECT 1 AS [C1] FROM [dbo]. [QualityAlertRules] AS [Extent2] Where [Extent2]. [Code] = [Extent1]. [Code]) [Extent1] . [Code] ASC  

Comments