Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Convert this query int LINQ..possible??

Hello, I would like, if possible, to convert this SQL query into LINQ. Basically is a group query that joins to itself.

select t1.invoiceno  from testdups as t1
left join testdups as t2 on t1.InvoiceNo = t2.invoiceno
where t1.IsInvoice <> t2.IsInvoice
group by t1.invoiceno
having count(t1.invoiceno)> 1

thanks!
0
arcross
Asked:
arcross
1 Solution
 
Fernando SotoCommented:
Hi arcross;

Give this a try to see if it comes out with what you are looking for.

Dim result = From t1 in DataContextInstance.testdups _
             Join t2 in DataContextInstance.testdups On t1.InvoiceNo = t2.InvoiceNo _
             Where t1.IsInvoice <> t2.IsInvoice _
             Group t1 By Key = t1.InvoiceNo Into Group _
             Where Group.Count > 1 _
             Select Group.Key

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now