Reputation: 2750
The situation is , I have a table which has for example 10 rows. I want to calculate the value of 'price' column and want to select the complete row ehich has MAX price.
var offer = (from p in dc.CustomerOffer
join q in dc.OffersInBranch
on p.ID equals q.OfferID
where q.BranchID == singleLoc.ID
select (p.OriginalPrice - p.NewPrice) * 100 / p.OriginalPrice).Max();
The above code gives me only the MAX price, How would I select the whole row. Any ideas guys??
Upvotes: 0
Views: 157
Reputation: 7268
Try the following code :
var offer = (from p in dc.CustomerOffer
join q in dc.OffersInBranch
on p.ID equals q.OfferID
where q.BranchID == singleLoc.ID
let value = (p.OriginalPrice - p.NewPrice) * 100 / p.OriginalPrice
order by value desc
select p).First()
Note : This is a dummy code and it might not be syntactically correct. You might have to tweak the query as per your requirement.
Upvotes: 1