public static async Task<APIAccount> FindByNameAsync(string name) { #if ENTITY_FRAMEWORK_6 || ENTITY_FRAMEWORK_7 using (var ctx = new TContext()) { return await ctx.APIAccounts.FirstOrDefaultAsync(x => x.Username == name); } #elif DAPPER using (var ctx = DatabaseFactory.CreateConnection()) { using (var txn = ctx.BeginTransaction()) return await ctx.FirstOrDefaultAsync<APIAccount>(new { Username = name }, transaction: txn); } #else return null; #endif }