Created
January 12, 2015 17:47
-
-
Save matijagrcic/2fc275c12f9862e37834 to your computer and use it in GitHub Desktop.
Glimpse with Dapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class BaseRepository | |
| { | |
| internal static async Task<List<T>> Query<T>(string sql, object param = null) | |
| { | |
| //we use DbProviderFactories instead of SqlConnection so we can get nice results in Glimpse under SQL tab | |
| var factory = DbProviderFactories.GetFactory(new SqlConnection()); | |
| using (var connection = factory.CreateConnection()) | |
| { | |
| connection.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; | |
| var results = await connection.QueryAsync<T>(sql, param); | |
| return results.ToList(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment