Enterprise library caching parameters on stored procs?

浪子不回头ぞ 提交于 2019-12-05 20:28:01

It definetly used to, I ripped the code out and threw in in my library.

it used sp_help and parsed the output to determine the data types.

These days, I ripped the code out, .Net is much much better about adding parameters.

cmd.Parameters.AddWithValue("@name",somevalue)

in your example of you keep reflectoring ... you will find it being done down this path GetStoredProcCommand()

You will get a Command object back, already populated with parameters

The ent lib code is copyrighted, but the code is almost identical to this

http://code.google.com/p/dbdotnet/source/browse/trunk/ParameterCache.cs

As far as I can tell it doesn't cache the parameters. Using the same instance of a Database object I called DiscoverParameters multiple times while running a trace. Each time I call DiscoverParameters I can see a [sys].[sp_procedure_params_100_managed] so it looks like it's making the round trip every time.

Here's an example of how to do it yourself that's seems like it might be alright:

http://davidhayden.com/blog/dave/archive/2006/11/03/CachingStoredProcedureParameters.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!