Solved

Best way to write Linq Query with inner select

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

13 Experts available now in Live!

Get 1:1 Help Now