public static async Task <T> QuerySingleCmdAsync <T>(this SqlConnection con, CommandDefinition commandDefinition, LogMemoryService log = null) { try { var data = await con.QueryFirstOrDefaultAsync <T>(commandDefinition); log?.AddToLog(GetSuccessMsg(commandDefinition)); return(data); } catch (TaskCanceledException tex) { log?.ErrorToLog(GetCancelledErrorMsg(commandDefinition, tex)); return(default);
public static List <T> QueryCmd <T>(this SqlConnection con, CommandDefinition commandDefinition, LogMemoryService log = null) { try { var data = con.Query <T>(commandDefinition); log?.AddToLog(GetSuccessMsg(commandDefinition)); return(data.ToList()); } catch (TaskCanceledException tex) { log?.ErrorToLog(GetCancelledErrorMsg(commandDefinition, tex)); return(new List <T>()); } catch (Exception ex) { log?.ErrorToLog(GetErrorMsg(commandDefinition, ex)); throw new Exception( GetExceptionMsg(con, commandDefinition, ex)); } }