コード例 #1
0
        public static APIAccount FindByName(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 ctx.FirstOrDefault<APIAccount>(new { Username = name }, transaction: txn);
            }
#else
            return null;
#endif
        }