Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I convert this SQL into vb.net LINQ statement

Posted on 2011-05-11
2
Medium Priority
?
334 Views
Last Modified: 2012-05-11
I have got a SQL statement that I need to convert into a VB.NET LINQ statement.

Please see the below SQL statement.

Any help would be appericated.
SELECT cu_cursym, sum(netamount)
FROM BORDEREAU t1
INNER JOIN COMMON.CU t2 ON t1.ORIGCURRENCY = t2.CU_CURCDE
WHERE (t1.COVERCONTRACT = 'B09001074') AND (t1.BORDEREAUNO = 5)
group by cu_cursym

Open in new window

0
Comment
Question by:bmsdev
2 Comments
 
LVL 27

Assisted Solution

by:MikeToole
MikeToole earned 800 total points
ID: 35745488
The attached query, which groups orders by customer, should start you off.


Dim Q = From Cust In Customers, Ord In Orders
                Where Cust.CustomerID = Ord.CustomerID
                Group Ord By Cust Into
                MaxID = Max(Ord.OrderID),
                MinID = Min(Ord.OrderID)

        For Each obj In Q
            Console.WriteLine(String.Format("Customer: {0}, Min: {1}, Min: {2}", obj.Cust.CustomerID, obj.MinID, obj.MaxID))
        Next

Open in new window

0
 
LVL 13

Accepted Solution

by:
jeebukarthikeyan earned 1200 total points
ID: 35745494
hi

try this way

var query = from client in _dataContext.AllClients   
join BORDEREAU in discounts on client equals BORDEREAU.ORIGCURRENCY into t1 
join COMMON in orders on client equalsCOMMON.CU_CURCDE into t2
where (t1.COVERCONTRACT = 'B09001074'  ) && (t1.BORDEREAUNO = 5)

select new 

{
cu_cursym,
t1.sum(netamount)
};

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

578 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