Solved

How to write linq for the below sql query

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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