// https://www.learnentityframeworkcore.com/dbset/querying-data
        public override async Task <User> GetSingleAsync(Expression <Func <User, bool> > predicate, bool disableTracking = true, CancellationToken cancellationToken = default(CancellationToken))
        {
            User user = null;

            try
            {
                user = await DatabaseSet
                       .Include(cmp => cmp.Employee).ThenInclude(emp => emp.EmployeeAddress)
                       .Include(cmp => cmp.Employee).ThenInclude(emp => emp.Department)
                       .AsNoTracking()
                       .SingleOrDefaultAsync(predicate, cancellationToken);

                return(user);
            }
            catch (Exception)
            {
                return(user);
            }
        }
Пример #2
0
        // https://www.learnentityframeworkcore.com/dbset/querying-data
        public override async Task <Company> GetSingleAsync(Expression <Func <Company, bool> > predicate, bool disableTracking = true, CancellationToken cancellationToken = default(CancellationToken))
        {
            Company company = null;

            try
            {
                company = await DatabaseSet
                          .Include(cmp => cmp.Employees).ThenInclude(emp => emp.EmployeeAddress)
                          .Include(cmp => cmp.Employees).ThenInclude(emp => emp.Department)
                          .Include(cmp => cmp.Employees).ThenInclude(emp => emp.User)
                          .AsNoTracking()
                          .SingleOrDefaultAsync(predicate, cancellationToken).ConfigureAwait(false);

                return(company);
            }
            catch (Exception)
            {
                return(company);
            }
        }
Пример #3
0
        public override async Task <Employee> GetSingleAsync(Expression <Func <Employee, bool> > predicate, bool disableTracking = true, CancellationToken cancellationToken = default(CancellationToken))
        {
            Employee employee = null;

            try
            {
                // https://www.learnentityframeworkcore.com/dbset/querying-data
                employee = await DatabaseSet
                           .Include(emp => emp.Company)
                           .Include(emp => emp.Department)
                           .Include(emp => emp.EmployeeAddress)
                           .Include(emp => emp.User)
                           .AsNoTracking()
                           .SingleOrDefaultAsync(predicate, cancellationToken).ConfigureAwait(false);

                return(employee);
            }
            catch (Exception)
            {
                return(employee);
            }
        }