?
Solved

Linq syntex help

Posted on 2010-08-15
3
Medium Priority
?
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 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