views:

29

answers:

1

The question is: Given a database backend that understands LeftStr and RightStr: where, in a custom ADO.NET provider implementation, would I establish a mapping to the immutable EDM canonical functions Left and Right?


So I am working with the SQLite ADO.NET provider and it works, more or less, until you bump up against some string functions that are present but named differently. Amongst the missing/mismapped functions are the canonical string functions Left and Right.

In the SQLite extension the equivalent functions are mapped to LeftStr and RightStr.

I have come up short when looking for information. Lacking documentation for this scenario, or my lack of ability in finding it, I have step traced the call all the way into the factory method that creates the command with the generated SQL and suspect that the SemanticResolver is my best clue, but I have taken a few stabs in the dark by fudging with the only exposed seam I can find, ProviderManifest.xml, but am having no joy.

+1  A: 

The answer assumes that SampleEntityFrameworkProvider is the reference implementation.

Each sql command to be executed against a provider implementation is processed by SampleEntityFrameworkProvider.SampleProviderServices.CreateDbCommandDefinition.

This method calls CreateCommand which in turn passes the DbCommandTree to SampleEntityFrameworkProvider.SqlGenerator, which is of type DbExpressionVisitor.

SqlGenerator's initializes static dictionaries of to handle translation.

I found what I was looking for in SqlGenerator.InitializeCanonicalFunctionHandlers and just followed the pattern as shown.

Simply add a new handler method to the dictionary keyed on the name of the EDM function you want to handle.

In this case the handler just needed to rename the function before it was written out.

Again there is a default implementation of this functionality, HandleFunctionDefaultGivenName(DbFunctionExpression e, string storeFunctionName).

Sky Sanders

related questions