/// <summary> /// Gets a user using the specified id /// </summary> /// <param name="id">Id of the user to be fetched</param> /// <returns></returns> public SimpleUserModel GetSimpleById(int id) { SimpleUserModel user = ( SimpleUserModel )ContextExtensions.GetCachedUserData("simpu_" + id); if (user != null) { return(user); } // Parameters List <object> parameters = new List <object>() { { new SqlParameter("uid", id) } }; string query = "SELECT u.Id, u.Name, u.Surname, u.Email, u.IdNumber, u.Branch, u.Name + ' ' + u.Surname AS DisplayName FROM [dbo].[Users] u WHERE u.Id=@uid"; user = context.Database.SqlQuery <SimpleUserModel>(query.Trim(), parameters.ToArray()).FirstOrDefault(); ContextExtensions.CacheUserData("simpu_" + id, user); return(user); }