/images/myAvatar200.png

Dapper: How to change CommandDefinition parameters values

Overview In my current development I’m using Dapper, a light ORM to access the database. Using Dapper is really easy and provides super-fast performance. Here’s an example of use: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 public async Task<List<T>> GetSomeDataAsync<T>( DateTime startDate, DateTime endDate, CancellationTokenSource sourceToken = null) { if (sourceToken == null) sourceToken = new CancellationTokenSource(); using (var con = CreateConnection()) { var sql = @"SELECT (your field list) FROM (your table/view/function))( @StartDate, @EndDate)"; var command = CreateCommand(sql, new { @StartDate = startDate, @EndDate = endDate }, cancellationToken: sourceToken.

Retrieving events from SQL Server

Overview When executing some long-running server side processes on a SQL Server (Stored procedures or functions) would be nice to get progress messages, and why not, a percent value in order to show a progress bar in our application. In the past I’ve used different techniques to archive this, from SQL Assemblies for calling a SignalR server, to execute xp_cmdshell, and so many other esoteric ways. None of that solved the problem in an elegant way, but well, it worked… more or less…

Getting data from OLAP cubes

Overview Recently I had to read some data from different OLAP cubes and show this information in our application. This could be accomplished using ADOMD.NET client library, which is the multidimensional equivalent to the ADO.NET libraries. This library provides a set of classes (Connections, Commands and Readers) that allow developers to connect, query and get data from these multidimensional sources in the same way the classical ADO.NET library does. Maybe the easiest way to read data is using the class AdomdDataReader.

Connect via SFTP using SSH.NET

Overview In these times of APIs-everywhere, it may sound like an anachronism the use SFTP to connect to a remote server and get a list of files for exchanging information, but in the financial world (sadly) it’s more common than you think. In my current project I’ve to connect to a remote server via Secure File Transfer Protocol (aka SFTP) using a user name, a RSA private key and a phassphrase.

Remove diacritics (accents) in strings

Quick note How to remove diacritics (accents) from a C# string? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 public static string RemoveDiacritics(this string input) { var stFormD = input.Normalize(NormalizationForm.FormD); var len = stFormD.Length; var sb = new StringBuilder(); for (int i = 0; i < len; i++) { var uc = System.Globalization.CharUnicodeInfo.GetUnicodeCategory(stFormD[i]); if (uc != System.Globalization.UnicodeCategory.NonSpacingMark) { sb.Append(stFormD[i]); } } return (sb.

Extract extra large icon from a file, folder or drive

Extracting system icons from Win32 Overwiew Hi, everyone! :) In a recent project I was required to show a list of files with their associated icons. It doesn’t sounds quite difficult, and in fact it is not. Except if you have to deal with files in network paths or you want to get different icons sizes, apart the typical 32×32. And well, that was the case If you only need local files and sizes of 32x32 píxels you can achieve this using the static method ExtractAssociatedIcon in the class System.