Is it a must in repository pattern to create models for each database tables? or can I create a model that can be placeholder of two or more database tables?
How to design Model class in Repository pattern?
420 Views Asked by aj go At
1
There are 1 best solutions below
Related Questions in MODEL
- Can raw means and estimated marginal means be the same ? And when?
- Can't load the saved model in PyTorch
- Question answering model for determine TRL(Technology Readiness Levels)
- Cannot trace my own model using torch.jit.trace
- Get json field value in sqlite model from view django
- Loading the pre-trained model from the .h5 file (Works on Colab but does not work on Local)
- how to get a model in js for odoo 16
- Is there a way to connect two models in mern and access user id of other model
- Using service in the constructor of a MODEL (angular)
- Beta coefficient of direct effect increases after controlling for mediator
- Running a pretrained model on real-time applications
- How to create two separate sets of data (one for daylight hours and another for nighttime hours) from hourly netcdf model output using CDO
- How to understand the Sensor Setting Property ID in the SIG Mesh model
- ValueError: Unknown layer: 'Custom>TFMPNetMainLayer'
- How to generate thumbnail images or GIFs from .GLB 3D models in Python?
Related Questions in REPOSITORY-PATTERN
- Repository manager receives the wrong connection string in .net core
- Using Repository pattern to fetch data from different places and build list of objects
- repository design pattern identitydbcontext problem
- I am getting this error in identitydbcontext in repository model design
- Blazor page what is the best way to get data based on various filtered conditions from the server's controller?
- Conditionnal repositories in Golang
- How to use EF Core 8's ExecuteUpdate() and ExecuteDelete() in a generic repository while keeping its interface agnostig from EF Core
- Facing Issue on Mapping Parent Child Relation Table using Automapper in C#
- How to avoid "The instance of entity type 'xx' cannot be tracked" exception in ASP.NET Core & EF Core
- MediatR Pattern CleanArchitecture with ASP.NET Core Web API
- how to achieve model-specific type inference from prisma model without explicitly passing the index string to PrismaClient object?
- MVC pattern combined with Repository pattern in Laravel?
- Polymorphism & Clean Architecture
- how to create a repository in GitHub
- How to register every IRepository interfaces via Dependency Injection?
Related Questions in REPOSITORY-DESIGN
- repository design pattern identitydbcontext problem
- Executable with many sources in subdirectories - should they be collected into libraries?
- Using the generic repository approach, how can you provide the navigation property filters that EF has in its latest versions?
- How do I Implement the Repository and Unit of Work Patterns in an ASP.NET WEB API Application?
- should I upload/add another repository to my new project repository? If so, how to avoid git wanting to add this?
- How to import changes from a GitHub template?
- DDD: The problem with domain services that need to fetch data as part of their business rules
- In which API layer (repository/service) to place custom SQL queries logic?
- Repository pattern: isn't getting the entire domain object bad behavior (read method)?
- Can you Rebase and/or Merge into the same Master Branch?
- Spring Data Repository with several entities
- What is the best way to track multi language projects in Git?
- Where should I put query logic related to filtering data by role user in DDD architecture
- Android architecture LiveData and Repositories
- GitHub social media image is not refreshed on update
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
In repository, there are multiple approaches to design the model depending on the need. So, better focus on business need. I will try to explain a bit.
Aggregate Root:
If you are doing Domain Driven Design, one entity per multiple tables is the approach generally taken. This is called Aggregate Root. Aggregate Root may contain multiple and nested Aggregates. So, this looks like some complex class hierarchy.
Benefit is that, your model become more friendly with your domain than your database. This truly helps persistence agnostic development. Primary focus of developer is shifted from persistence needs to domain instead.
Not part of your question though, this also helps taking most benefit from the full ORM if your using any.
This approach is generally over kill for small projects.
Model per Table:
This is very simple approach generally taken for small applications; specially, if you are not doing DDD. If your application is more a database oriented (like CRUD) than domain, then this approach is preferred. You may not be able to use some of the good features of full ORM with this like extensive mapping capabilities, lazy loading etc.