コード例 #1
0
        public static async Task<APIAccountRole[]> GetRolesForAccount(long accountId)
        {
#if ENTITY_FRAMEWORK_6 || ENTITY_FRAMEWORK_7
            using (var ctx = new TContext())
            {
                return await ctx.APIAccountsRoles.Where(x => x.AccountId == accountId).ToArrayAsync();
            }
#elif DAPPER
            using (var ctx = DatabaseFactory.CreateConnection())
            {
                using (var txn = ctx.BeginTransaction())
                    return (await ctx.WhereAsync<APIAccountRole>(new { AccountId = accountId }, transaction: txn)).ToArray();
            }
#else
            return null;
#endif
        }