Esempio n. 1
0
        public TestResult GetTeamMemberByProject(int projectId)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            List <TeamMember> teamMembers = new List <TeamMember>();
            TestResult        result      = new TestResult();

            using (EfCoreDbContext context = new EfCoreDbContext(_connectionString))
            {
                teamMembers = context.Teams.AsNoTracking()
                              .Include(x => x.TeamMembers)
                              .Where(x => x.ProjectID == projectId)
                              .SelectMany(x => x.TeamMembers)
                              .Select(x => new TeamMember
                {
                    ID          = x.ID,
                    DateOfBirth = x.DateOfBirth,
                    FirstName   = x.FirstName,
                    LastName    = x.LastName,
                    TeamID      = x.TeamID
                }).OrderBy(x => x.FirstName).ToList();
            }

            watch.Stop();
            result.MemberCount = teamMembers.Count;
            result.Time        = watch.ElapsedMilliseconds;
            return(result);
        }
Esempio n. 2
0
        public TestResult GetTeamMemberByID(int id)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            TestResult result = new TestResult();

            using (EfCoreDbContext context = new EfCoreDbContext(_connectionString))
            {
                var teamMemberEF = context.TeamMembers.Find(id);
                _ = new TeamMember()
                {
                    ID          = teamMemberEF.ID,
                    DateOfBirth = teamMemberEF.DateOfBirth,
                    FirstName   = teamMemberEF.FirstName,
                    LastName    = teamMemberEF.LastName,
                    TeamID      = teamMemberEF.TeamID
                };
            }

            watch.Stop();
            result.MemberCount = 1;
            result.Time        = watch.ElapsedMilliseconds;
            return(result);
        }