repository-pattern

Android Kotlin Room Repository unable to retrieve row from within detail activity

梦想的初衷 提交于 2021-02-20 01:00:08
问题 I'm really struggling with this & would appreciate some help please. I'm learning Android Kotlin & building an app that displays a list of walking routes (downloaded from the cloud) in a RecyclerView &, when a route is selected I want to display all details of the route - a simple Master-Detail app. Since, I'm learning I also want to try and use best practice. I have most of it working fine using a Room database & a Repository. The database is correctly populated and the RecyclerView displays

Generic Unit Of Work

六月ゝ 毕业季﹏ 提交于 2021-02-07 09:26:33
问题 I have implemented EntityFramework pattern along with Repository and Unit Of Work. The implementation is similar to Code Project Repository Example, however I need an enhancement for the Unit Of Work. The unit of work public class GenericUnitOfWork : IDisposable { // Initialization code public Dictionary<Type, object> repositories = new Dictionary<Type, object>(); public IRepository<T> Repository<T>() where T : class { if (repositories.Keys.Contains(typeof(T)) == true) { return repositories

How to test repository with junit5 and testcontainers?

六月ゝ 毕业季﹏ 提交于 2021-01-29 08:12:19
问题 I have a sample project in which I experiment with different technologies. I have the following setup: Spring Boot 2.3.4.RELEASE Flyway 7.0.1 Testcontainers 1.15.0-rc2 Junit 5.7.0 How can I test the Repository layer with testcontainer-junit5? Example of code I have now for CompanyRepositoryTest.java : @ExtendWith(SpringExtension.class) @Testcontainers public class CompanyRepositoryTest { @Autowired private CompanyRepository companyRepository; @Container public MySQLContainer mysqlContainer =

Repository, Service or Domain object - where does logic belong?

Deadly 提交于 2021-01-27 03:55:57
问题 Take this simple, contrived example: UserRepository.GetAllUsers(); UserRepository.GetUserById(); Inevitably, I will have more complex "queries", such as: //returns users where active=true, deleted=false, and confirmed = true GetActiveUsers(); I'm having trouble determining where the responsibility of the repository ends. GetActiveUsers() represents a simple "query". Does it belong in the repository ? How about something that involves a bit of logic, such as: //activate the user, set the

Repository, Service or Domain object - where does logic belong?

喜欢而已 提交于 2021-01-27 03:55:20
问题 Take this simple, contrived example: UserRepository.GetAllUsers(); UserRepository.GetUserById(); Inevitably, I will have more complex "queries", such as: //returns users where active=true, deleted=false, and confirmed = true GetActiveUsers(); I'm having trouble determining where the responsibility of the repository ends. GetActiveUsers() represents a simple "query". Does it belong in the repository ? How about something that involves a bit of logic, such as: //activate the user, set the

Repository, Service or Domain object - where does logic belong?

久未见 提交于 2021-01-27 03:53:56
问题 Take this simple, contrived example: UserRepository.GetAllUsers(); UserRepository.GetUserById(); Inevitably, I will have more complex "queries", such as: //returns users where active=true, deleted=false, and confirmed = true GetActiveUsers(); I'm having trouble determining where the responsibility of the repository ends. GetActiveUsers() represents a simple "query". Does it belong in the repository ? How about something that involves a bit of logic, such as: //activate the user, set the

Unit Testing the Repository Pattern Without EF [closed]

那年仲夏 提交于 2021-01-20 13:40:07
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 18 hours ago . Improve this question I have created a simple Web API that interfaces with a MySQL Database. I am old school and like using SqlConnection/SqlCommand classes to interact with the database, no ORM/no EF. I have created a MySQL DbContext so that I can use DI to inject the MySQL specifics and

Node js Sequelize repository pattern (node:2944) UnhandledPromiseRejectionWarning: TypeError: is not a function

假装没事ソ 提交于 2020-12-15 03:47:23
问题 I recently got aware of repository pattern. I am quite new to this pattern and tried to shift my code in this patter. I am using Node js and Sequelize ORM with Sqlite database. Following route is working router.get('/listquestions',(req,res)=>{ Question.findAll({ attributes: ['id','title'], include: [{ model:Lecture, attributes: ['id','videoname','coursecode'], }] }).then((questions) => { if(questions){ console.log(JSON.stringify(questions)); res.render('pages/questionslist', {data:questions}

Node js Sequelize repository pattern (node:2944) UnhandledPromiseRejectionWarning: TypeError: is not a function

﹥>﹥吖頭↗ 提交于 2020-12-15 03:45:10
问题 I recently got aware of repository pattern. I am quite new to this pattern and tried to shift my code in this patter. I am using Node js and Sequelize ORM with Sqlite database. Following route is working router.get('/listquestions',(req,res)=>{ Question.findAll({ attributes: ['id','title'], include: [{ model:Lecture, attributes: ['id','videoname','coursecode'], }] }).then((questions) => { if(questions){ console.log(JSON.stringify(questions)); res.render('pages/questionslist', {data:questions}

How to make parallel async queries in EF Core 3.0 with repository pattern?

岁酱吖の 提交于 2020-12-11 09:10:03
问题 I have repository like public interface IEmployeeRepository { Task<EmployeeSettings> GetEmployeeSettings(int employeeId); Task<ICollection<DepartmentWorkPosition>> GetWorkPositions(int employeeId); } Constructor of repository (DbContext injection): public EmployeeRepository(EmployeeDbContext dbContext) { _dbContext = dbContext; } And call it in EF Core 2.0 like var settingsTask = _employeeRepository .GetEmployeeSettings(employeeId.Value); var workPositionsTask = _employeeRepository