/// <summary> /// Удалить значения из таблицы /// </summary> /// <param name="predicate">Фильтр удаления записи</param> /// <returns>Количество удаленных значений</returns> public async Task <int> Delete(Expression <Func <TEntity, bool> > predicate) { using (IDataConnection connection = _connectionFactory.Create()) { var count = await connection.From <TEntity>().Where(predicate).DeleteAsync(); return(count); } }
/// <summary> /// Получить список моделей сотрудников /// </summary> /// <returns> Список моделей сотрудников</returns> public async Task <List <EmployeeModel> > GetAllWithDepartment() { using (IDataConnection connection = _connectionFactory.Create()) { return(await connection.From <Employee>() .Join(connection.From <Department>(), employee => employee.DepartmentId, department => department.Id, (employee, department) => new EmployeeModel { Department = department.Name, Address = employee.Address, Birthday = employee.Birthday, Details = employee.Details, Name = employee.Name, Patronymic = employee.Patronymic, Surname = employee.Surname, Id = employee.Id }) .ToListAsync()); } }
/// <summary> /// Получить список значений таблицы /// </summary> /// <returns>Список значений</returns> public async Task <List <TEntity> > GetAll() { using (IDataConnection connection = _connectionFactory.Create()) { return(await connection.From <TEntity>().ToListAsync()); } }
public List <TEntity> GetAll() { using (IDataConnection connection = _connectionFactory.Create()) { return(connection.From <TEntity>().ToList()); } }