[dba-VB] Using aggregate SQL functions (Count(). Max(), ...) in ADO.NET EF queries in .NET Frame

Gustav Brock Gustav at cactus.dk
Wed Jun 30 03:45:19 CDT 2010

Hi Shamil

So what you tell is that no ".Max()" is at hand or usable in your expression? Or am I missing something?


>>> shamil at smsconsulting.spb.ru 30-06-2010 07:47 >>>
Hi Gustav --

Thank you for your advice.
Still I have had to use ORDER BY ... DESC to find the last record (this is a
one user application with MS SQL backend) - I cannot find what EF LINQ
expression should be used to get max ID value - I still have to learn a lot
about EF LINQ here...

-- Shamil

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com 
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Friday, June 25, 2010 8:24 PM
To: dba-vb at databaseadvisors.com 
Subject: Re: [dba-VB] Using aggregate SQL functions (Count(). Max(),...) in
ADO.NET EF queries in .NET Framework

Hi Shamil

I have nothing running at the moment on this computer, but isn't it similar
to this (from examples in LinqPad):

For example, the following query will work on the NORTHWND sample database:

from p in Products
let spanishOrders = p.OrderDetails.Where (o => o.Order.ShipCountry == "Spain")
where spanishOrders.Any()
orderby p.ProductName
select new
	Orders = spanishOrders.Count(),	
	TotalValue = spanishOrders.Sum (o => o.UnitPrice * o.Quantity)

or as shown here:



>>> shamil at smsconsulting.spb.ru 25-06-2010 11:21 >>>
Hi All,

I can't find is the subj available or not by using LINQ for Entities?
If it's not available do you have good samples' references on how to use
ObjectQuery<...> with custom SQL using aggregare SQL functions?...

Thank you.

-- Shamil

More information about the dba-VB mailing list