Solved

How to write linq for the below sql query

Posted on 2014-10-03
1
102 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
query help 18 50
Default parameter problem in C# 3 26
How do I bind the results to a grid 3 22
Expando 4 33
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

11 Experts available now in Live!

Get 1:1 Help Now