Solved

Best way to write Linq Query with inner select

Posted on 2014-01-13
1
268 Views
Last Modified: 2016-02-10
I have a tsql query that I want to write as a linq query. what is the best way to handle the inner select.

SELECT        *
FROM           tblOffers where RequestID = 1004 and OfferID = (Select max(OfferID) from tblOffers where RequestID =1004)

Open in new window

0
Comment
Question by:NickMalloy
[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 16

Accepted Solution

by:
Easwaran Paramasivam earned 350 total points
ID: 39777799
You should from linq query like given below.

var result  =from t in from 
                    ddr in tblOffers 
                    group ddr by ddr.OfferID into g
                    select new { MaxOfferID = g.Max(x => x.OfferID ), g.RequestID}
                    join ddr in tblOffers on t.OfferID  equals ddr.MaxOfferID 
                    where t.RequestID  == 1004 
                    select new { t.RequestID , t.OfferID  };

Open in new window

0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

627 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