Enterprise library caching options in stored procedures?

I am trying to standardize a data access code with my colleagues. One of the aforementioned colleagues claims that the EntLib data access unit is trying to cache parameters for stored proc calls.

I looked into the reflector, and there is some evidence that it can cache them. But I do not think that this happens in the following situation.

    public Dictionary<long, string> GetQueue(int maxItems)
    {
        var sq = new SqlDatabase(_connString.ConnectionString);

        var result = new Dictionary<long, string>();

        using (var cmd = (SqlCommand)sq.GetStoredProcCommand("dbo.GetQueue"))
        {
            sq.AddInParameter(cmd, "maxItems", DbType.Int32, maxItems);

            var reader =  cmd.ExecuteReader(CommandBehavior.CloseConnection);

            while (reader.Read())
            {
                long id = reader.GetInt64(reader.GetOrdinal("id"));
                string fileName = reader.GetString(reader.GetOrdinal("meta_data_filename"));

                result.Add(id, fileName);
            }
        }

        return result;
    }

Can anyone confirm or deny this?

I am using EntLib 4.1

+3
source share
2 answers

He was definitely used to it, I pulled out the code and threw it into my library.

sp_help .

,.Net .

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

... , GetStoredProcCommand()

Command ,

ent lib ,

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

+3

, . , DiscoverParameters . , DiscoverParameters, [sys]. [Sp_procedure_params_100_managed], , .

, , , :

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

+2

Source: https://habr.com/ru/post/1705705/


All Articles