ExecuteSqlStringAccessor

Topics: Data Access Application Block
Apr 19, 2010 at 11:50 AM

Hi,

Is there any way of passing parameterized queries to this method? Also, where can I find the official documentation for version 5?

Thanks

Apr 20, 2010 at 12:52 AM
Edited Apr 20, 2010 at 12:53 AM

There's currently no overload of this method that accepts parameter values but as a workaround, you can call the CreateSqlStringAccessor and then call the Execute method against the resulting object.  The Execute method allows you to pass parameter values.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
  

Apr 20, 2010 at 8:58 AM

Thanks... probably a noob question, but how would I go about using the IParameterMapper to pass in the parameters? Is there any documentation on it? From my quick google, there is none that I can find.

Apr 20, 2010 at 9:00 AM

Forgot to mention, the Execute method (passing in parameters) throws the following exception:

 

Sql String Accessor cannot be used to discover parameters. Use an IParameterMapper instead.

Apr 20, 2010 at 9:28 AM
Edited Apr 20, 2010 at 9:39 AM

The documentation for using accessors is included in the documentation when you install the Beta 2 release.  You're working against an SQL Database, am I right? I'm not sure about the error message about using an IParameterMapper, I'll need to investigate further and see if it's a bug.  But for now, you can opt to create your own implementation of IParameter.  It is also included in the documentation (Returning Data as Objects for Client Side Querying -> Defining Parameter Mappers).

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
  

Apr 20, 2010 at 9:45 AM

Ah, I have downloaded the latest source... hence no docs. will get beta 2 installed for docs. thanks for the assist.

Apr 20, 2010 at 11:24 AM

Just an update, you are indeed expected to create your own implementation of IParameterMapper and use it when creating an sqlstringaccessor and executing a parameterized query.  It isn't a bug as what admittedly was, my first impression.

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
  

Apr 20, 2010 at 11:26 AM

I have done this, and can confirm it works as advertised.