Solved

How to write linq for the below sql query

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

Industry Leaders: 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!

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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