Solved

How to write linq for the below sql query

Posted on 2014-10-03
1
106 Views
Last Modified: 2016-02-15
I am trying to write linq to sql query and have just started with linq.

How can I write linq for the following query

select * from SP_FORM where SP_FORM_ID in ( 
select SP_FORM_ID from SP_FORM_PAGES group by SP_FORM_ID having count(*)>1
)

Open in new window


Any help will be appreciated.

Thanks.
0
Comment
Question by:developer2012
1 Comment
 
LVL 11

Accepted Solution

by:
louisfr earned 500 total points
ID: 40360131
If all the names are the same in the code, the equivalent Linq would be
from form in SP_FORM
where (from page in SP_FORM_PAGES
       group page by page.SP_FORM_ID into g
       where g.Count() > 1
       select g.Key).Contains(form.SP_FORM_ID)
select item;

Open in new window

A join might be more efficient.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

896 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

12 Experts available now in Live!

Get 1:1 Help Now