Solved

Best way to write Linq Query with inner select

Posted on 2014-01-13
1
265 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 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