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')))
Who is Participating?
käµfm³d 👽Commented:
where did the o .customerid come from?
My fault--I forgot to change that piece. Try this VB version:

Dim query = From a In db.Table1 _
            Where a.Letter = "y" AndAlso Not (From b in db.Table2 _
                                              Where b.fk_Planid = "30" _
                                              Select b.ProductServiceName).Contains(a.Product_ProductServiceName) _
            Select New With _
            { _
                a.ProductServiceName = Product_ProductServiceName, _
                a.ProductClass = ProductClass _

Open in new window

käµfm³d 👽Commented:

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

mwhodgesAuthor Commented:
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.
mwhodgesAuthor Commented:
Thank you so much!!  It worked perfectly
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.