예제 #1
0
        /// <summary>
        /// Returns the user entity of the user with ID userID
        /// </summary>
        /// <param name="userId">The user ID.</param>
        /// <returns>entity with data requested or null if not found.</returns>
        public static async Task <UserEntity> GetUserAsync(int userId)
        {
            using (var adapter = new DataAccessAdapter())
            {
                var q = new QueryFactory().User.Where(UserFields.UserID.Equal(userId));
                if (userId == 0)
                {
                    // cache the resultset, as the anonymous user doesn't change
                    q.CacheResultset(3600, false, CacheKeys.AnonymousUserQueryResultset);
                }

                return(await adapter.FetchFirstAsync(q).ConfigureAwait(false));
            }
        }