[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Linq syntex help

Posted on 2010-08-15
3
Medium Priority
?
357 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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 …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

656 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