Solved

Best way to write Linq Query with inner select

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

912 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

20 Experts available now in Live!

Get 1:1 Help Now