Shawn Wildermuth - MVP (C#)

It would seem to me that as much as possible the EDM should focus on not mixing the storage model with the client code. That separation of responsibilities is one of the benefits Ilike with this model (and other products that espouse similar model). But there is a problem I think. Consider the following eSQL:

Code Snippet

SELECT SqlServer.MIN(p.UnitPrice) as Minimum,
SqlServer.AVG(p.UnitPrice) as Average,
SqlServer.MAX(p.UnitPrice) as Maximum
FROM EntityNorthwindContext.Products as p

OR (they are equivalent)

Code Snippet

using SqlServer;
SELECT MIN(p.UnitPrice) as Minimum,
AVG(p.UnitPrice) as Average,
MAX(p.UnitPrice) as Maximum
FROM EntityNorthwindContext.Products as p

The problem with this query is that it dictates that a common SQL aggregation like MIN, MAX or AVG are specific to SqlServer. it requires that I know about the storage model to write this very common query. Why aren't the aggregators (and other standard SQL pieces) not suported by provider unspecific functionality I understand why you wouldn't do this for some functionality that is not supported on all platforms (e.g. Full-text search), but for common SQL that is Standard SQL (or SQL 1999)...I don't see why this is necessary.

Comments




Re: ADO.NET (Pre-release) Confused by SqlServer Specific Functionality

Srikanth Mandadi - MSFT

We are going to provide this functionality in our next CTP.

The next CTP of the Entity Framework will include support for Canonical functions. Canonical functions are a set of functions that you will be able to use in ESql queries irrsepective of the store provider underneath. These canonical functions get mapped to the store specific functions at the runtime. The set of functions will be predefined by the EF stack but will include support for most common functions like Min, Max, Avg, Trim etc.

Thanks

Srikanth






Re: ADO.NET (Pre-release) Confused by SqlServer Specific Functionality

Daniel Simmons - MSFT

The one thing I will add is that in addition to the canonical functions in ESql we will continue to support the ability for providers to declare additional provider-specific functions. That way for many scenarios you can use canonical functions, but if you are in a situation where you know you will run a query against a specific provider and you need functionality which that provider has over and above the canonical functions, then you will still have access to the full spectrum of that provider's capabilities. Those functions will look like the ones in your example above.

- Danny