Solved

Linq syntex help

Posted on 2010-08-15
3
348 Views
Last Modified: 2013-11-11
       Dim Query = From Supp In db.Suppliers _
                           Group Join RO In db.ReceiveOrders _
                On RO.SupplierNo Equals Supp.SupplierID _
                Into RightTableResults = Group _
        From Contact In RightTableResults.DefaultIfEmpty _
             Select ContactName = If(Supp Is Nothing, Nothing, _
        If(Supp Is Nothing, New Supplier, Supp).ContactName), Supp.Name

This query works great, now I need to add this line to join in one more table:

 Join ROE In db.ReceiveEntries On RO.ReceiveID Equals ROE.ReceiveNo

I can't figure out how to do it, can some one help me with that?

(the SQL syntax is very simple:
SELECT     Supplier.Name, ReceiveEntry.Cost, ReceiveEntry.Qty, ReceiveOrder.ReceiveOrderDate
FROM         ReceiveEntry INNER JOIN
                      ReceiveOrder ON ReceiveEntry.ReceiveNo = ReceiveOrder.ReceiveID RIGHT OUTER JOIN
                      Supplier ON ReceiveOrder.SupplierNo = Supplier.SupplierID)
 
0
Comment
Question by:Mr_Ezi
3 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33441655
try this link there is an sql to linq Converter...
http://www.sqltolinq.com/
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 33443981
If there's a relationship in your database between ReceiveEntry and ReceiveOrder you should be able to simply add the receive entries to your select.

e.g. (don't know the VB syntax... but in C# it would be something like)
select new
{
    Supp.ContactName,  // replace this with the if statements you had
    Supp.Name,
    Entries = RO.ReceiveEntries
}
0
 
LVL 12

Accepted Solution

by:
kumar754 earned 500 total points
ID: 33534615
based on your code, try the attached linq query,
I guess you can easily convert it into VB.NET


 var query = from supp in db.Suppliers

	     join recOrder in db.ReceiveOrder

		on supp.SupplierID equals ReceiveOrder.SupplierNo into recOrderGroup

	     join recEntry in db.ReceiveEntry

		on recOrder.ReceiveID equals recEntry.ReceiveNo into recEntryGroup

	     from recOrder in recOrderGroup.DefaultIfEmpty()

	     from recEntry in recEntryGroup.DefaultIfEmpty()

	     select new {

		supp.Name, 

		recEntry.Cost, 

		recEntry.Qty, 

		recOrder.ReceiveOrderDate

	     };

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# GridRow get Old/New Value 1 55
How to use odbc in vb to connect to ms sql 14 26
Visual Studio 2015 Source Code Control 10 25
Advice in Xamarin 21 47
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now