Tomboi88 / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Feature request: Query shortcut for Stored Procedures #118

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
My shop exclusively uses stored procedures over inline SQL. To help keep it 
DRY, and to avoid repeatedly stating "commandType: 
CommandType.StoredProcedure", two additional extensions could be added.

Stored procedures are a common approach to data access, and I believe it would 
be appropriate to support their use without specifying it in a parameter.

Thank you.

Example below.

        public static IEnumerable<T> Sproc<T>(this IDbConnection cnn, string sql, dynamic param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null)
        {
            return Query<T>(cnn, sql, param, transaction, buffered, commandTimeout, CommandType.StoredProcedure);
        }

        public static IEnumerable<dynamic> Sproc(this IDbConnection cnn, string sql, dynamic param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null)
        {
            return Query(cnn, sql, param, transaction, buffered, commandTimeout, CommandType.StoredProcedure);
        }

Original issue reported on code.google.com by smdra...@gmail.com on 28 Sep 2012 at 1:43

GoogleCodeExporter commented 8 years ago
I don't see a need for that in the core library; the defaults all match the 
ADO.NET defaults. You can, of course, provide your own extension methods 
locally that do exactly this.

Original comment by marc.gravell on 6 Aug 2014 at 3:36