how can i write “in( select” method in linq?
I’m trying to convert :
UPDATE ActualAmountsByLocation SET isCustomerItem=1 WHERE ItemBarcode IN (SELECT barcode FROM StockMaterials WHERE barcode=@Barcode AND ownership=1)
I’ve tried like this:
Array stockMaterials = ( from s in stockMovementCtx.StockMaterials where s.barcode == Barcode && s.ownership ==1 select s).ToArray();
actualAmountsByLocation = (from a in stockMovementCtx.ActualAmountsByLocations
where a.ItemBarcode.Contains(stockMaterials)
select a).First();
To get an IN query you need to reverse the sense of the contains. Also, no need to materialize the first query, IMO.