Link to home
Start Free TrialLog in
Avatar of mwhodges
mwhodgesFlag for United States of America

asked on

sql to linq transformation

I need to change the following query to linq.  Please help

SELECT        Product_ProductServiceName, ProductClass
FROM            Table1 AS a
WHERE        (Letter = 'y') AND (Product_ProductServiceName NOT IN
                             (SELECT        ProductServiceName
                               FROM            Table2
                               WHERE        (fk_Planid = '30')))
Avatar of kaufmed
kaufmed
Flag of United States of America image

Try:

var query = from a in db.Table1
            where a.Letter == "y" && !(from b in db.Table2
                                       where b.fk_Planid == "30"
                                       select o.CustomerID).Contains(a.Product_ProductServiceName)
            select new
            {
                ProductServiceName = Product_ProductServiceName,
                ProductClass = ProductClass
            };

Open in new window

Avatar of mwhodges

ASKER

I'm using vb.net sorry.  I tried to do the conversion but I have a question where did the o .customerid come from?  Also when I get beyond the select new statment I get several other errors.  Thank you so much for your help.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much!!  It worked perfectly