コード例 #1
0
 public EmployeeClassification?GetByKey(int employeeClassificationKey)
 {
     using (var db = new OrmCookbook())
     {
         return(db.EmployeeClassification.Where(d => d.EmployeeClassificationKey == employeeClassificationKey).SingleOrDefault());
     }
 }
コード例 #2
0
 public async Task <EmployeeClassification> FindByNameAsync(string employeeClassificationName)
 {
     using (var context = new OrmCookbook())
     {
         return(await context.EmployeeClassifications.Where(ec => ec.EmployeeClassificationName == employeeClassificationName).SingleOrDefaultAsync());
     }
 }
コード例 #3
0
 public EmployeeClassification GetByKeyOrException(int employeeClassificationKey)
 {
     using (var db = new OrmCookbook())
     {
         return(db.EmployeeClassification.Where(ec => ec.EmployeeClassificationKey == employeeClassificationKey).Single());
     }
 }
コード例 #4
0
 public IList <EmployeeClassification> GetAll()
 {
     using (var db = new OrmCookbook())
     {
         return(db.EmployeeClassification.ToList());
     }
 }
コード例 #5
0
 public EmployeeClassification?FindByNameOrNull(string employeeClassificationName)
 {
     using (var db = new OrmCookbook())
     {
         return(db.EmployeeClassification.Where(ec => ec.EmployeeClassificationName == employeeClassificationName).SingleOrDefault());
     }
 }
コード例 #6
0
 public EmployeeClassification FindByNameOrException(string employeeClassificationName)
 {
     using (var db = new OrmCookbook())
     {
         return(db.EmployeeClassification.Where(ec => ec.EmployeeClassificationName == employeeClassificationName).Single());
     }
 }
コード例 #7
0
 public bool DeleteByKeyWithStatus(int employeeClassificationKey)
 {
     using (var db = new OrmCookbook())
     {
         return(1 == db.EmployeeClassification.Where(d => d.EmployeeClassificationKey == employeeClassificationKey).Delete());
     }
 }
コード例 #8
0
 public async Task <IList <EmployeeClassification> > GetAllAsync()
 {
     using (var context = new OrmCookbook())
     {
         return(await context.EmployeeClassifications.ToListAsync());
     }
 }
コード例 #9
0
 public async Task <EmployeeClassification> GetByKeyAsync(int employeeClassificationKey)
 {
     using (var context = new OrmCookbook())
     {
         return(await context.EmployeeClassifications.FindAsync(employeeClassificationKey));
     }
 }
コード例 #10
0
 public IList <Employee> PaginateWithSkipTake(string lastName, int skip, int take)
 {
     using (var db = new OrmCookbook())
         return(db.Employee.Where(e => e.LastName == lastName)
                .OrderBy(e => e.FirstName).ThenBy(e => e.EmployeeKey)
                .Skip(skip).Take(take).ToList());
 }
コード例 #11
0
 public async Task <IList <EmployeeClassification> > GetAllAsync(CancellationToken cancellationToken = default)
 {
     using (var db = new OrmCookbook())
     {
         return(await db.EmployeeClassification.ToListAsync().ConfigureAwait(false));
     }
 }
コード例 #12
0
 public IList <Division> GetAllDivisions()
 {
     using (var context = new OrmCookbook())
     {
         return(context.Divisions.ToList());
     }
 }
コード例 #13
0
 public Department GetByKey(int departmentKey)
 {
     using (var context = new OrmCookbook())
     {
         return(context.Departments.Include(d => d.Division).Where(d => d.DepartmentKey == departmentKey).SingleOrDefault());
     }
 }
コード例 #14
0
 public async Task <EmployeeClassification?> GetByKeyAsync(int employeeClassificationKey, CancellationToken cancellationToken = default)
 {
     using (var db = new OrmCookbook())
     {
         return(await db.EmployeeClassification.Where(d => d.EmployeeClassificationKey == employeeClassificationKey).SingleAsync().ConfigureAwait(false));
     }
 }
コード例 #15
0
 public IList <Department> GetAll()
 {
     using (var context = new OrmCookbook())
     {
         return(context.Departments.Include(d => d.Division).ToList());
     }
 }
 public override void Delete(int employeeClassificationKey)
 {
     using (var context = new OrmCookbook())
     {
         context.Database.ExecuteSqlCommand("DELETE FROM HR.EmployeeClassification WHERE EmployeeClassificationKey = @p0", employeeClassificationKey);
     }
 }
コード例 #17
0
 public virtual EmployeeClassification GetByKey(int employeeClassificationKey)
 {
     using (var context = new OrmCookbook())
     {
         return(context.EmployeeClassifications.Find(employeeClassificationKey));
     }
 }
コード例 #18
0
 public virtual IList <EmployeeClassification> GetAll()
 {
     using (var context = new OrmCookbook())
     {
         return(context.EmployeeClassifications.ToList());
     }
 }
コード例 #19
0
 public virtual EmployeeClassification FindByName(string employeeClassificationName)
 {
     using (var context = new OrmCookbook())
     {
         return(context.EmployeeClassifications.Where(ec => ec.EmployeeClassificationName == employeeClassificationName).SingleOrDefault());
     }
 }
コード例 #20
0
 public IReadOnlyList <ReadOnlyEmployeeClassification> GetAll()
 {
     using (var db = new OrmCookbook())
     {
         return(db.EmployeeClassification
                .Select(x => new ReadOnlyEmployeeClassification(x)).ToImmutableArray());
     }
 }
コード例 #21
0
 public ReadOnlyEmployeeClassification GetByKey(int employeeClassificationKey)
 {
     using (var db = new OrmCookbook())
     {
         return(db.EmployeeClassification.Where(d => d.EmployeeClassificationKey == employeeClassificationKey)
                .Select(x => new ReadOnlyEmployeeClassification(x)).Single());
     }
 }
 public override void Update(EmployeeClassification classification)
 {
     using (var context = new OrmCookbook())
     {
         context.Entry(classification).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #23
0
 public void Warmup()
 {
     //Make sure we can connect to the database. This will also pool a connection for future use.
     using (var db = new OrmCookbook())
     {
         db.EmployeeClassification.ToList();
     }
 }
コード例 #24
0
 public virtual void Update(EmployeeClassification classification)
 {
     using (var context = new OrmCookbook())
     {
         var temp = context.EmployeeClassifications.Find(classification.EmployeeClassificationKey);
         temp.EmployeeClassificationName = classification.EmployeeClassificationName;
         context.SaveChanges();
     }
 }
コード例 #25
0
 public EmployeeClassification?GetEmployeeClassifications(int employeeClassificationKey)
 {
     using (var db = new OrmCookbook())
     {
         return(db.QueryProc <EmployeeClassification>("HR.GetEmployeeClassifications",
                                                      new DataParameter("@EmployeeClassificationKey", employeeClassificationKey)
                                                      ).SingleOrDefault());
     }
 }
コード例 #26
0
 public IList <Employee> SortBy(string lastName, string sortByColumnA, bool isDescendingA,
                                string sortByColumnB, bool isDescendingB)
 {
     using (var db = new OrmCookbook())
         return(db.Employee.Where(x => x.LastName == lastName)
                .OrderBy(sortByColumnA, isDescendingA)
                .ThenBy(sortByColumnB, isDescendingB)
                .ToList());
 }
コード例 #27
0
 public virtual void DeleteByKey(int employeeClassificationKey)
 {
     using (var db = new OrmCookbook())
     {
         db.EmployeeClassification
         .Where(d => d.EmployeeClassificationKey == employeeClassificationKey)
         .Delete();
     }
 }
コード例 #28
0
 public async Task DeleteByKeyAsync(int employeeClassificationKey)
 {
     using (var db = new OrmCookbook())
     {
         await db.EmployeeClassification
         .Where(d => d.EmployeeClassificationKey == employeeClassificationKey)
         .DeleteAsync().ConfigureAwait(false);
     }
 }
コード例 #29
0
 public virtual int Create(EmployeeClassification classification)
 {
     using (var context = new OrmCookbook())
     {
         context.EmployeeClassifications.Add(classification);
         context.SaveChanges();
         return(classification.EmployeeClassificationKey);
     }
 }
コード例 #30
0
        public void InsertBatch(IList <Employee> employees)
        {
            var options = new BulkCopyOptions()
            {
                BulkCopyType = BulkCopyType.MultipleRows
            };

            using (var db = new OrmCookbook())
                db.BulkCopy(options, employees);
        }