Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Best way to write Linq Query with inner select

Posted on 2014-01-13
1
Medium Priority
?
271 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 1400 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

721 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