How to use the Repository Design Pattern in C# and ASP.NET

  Рет қаралды 13,557

tutorialsEU - C#

tutorialsEU - C#

Күн бұрын

Пікірлер: 17
@tutorialsEUC
@tutorialsEUC Жыл бұрын
🚀 C# Progress Academy - Become a job-ready C# and Angular web developer to land your dream developer role: bit.ly/45vbPUg
@imadabab
@imadabab 19 күн бұрын
This is by far the best video on the Repository Design Pattern in C# on KZbin. Thank you so much for sharing such valuable insights and explaining it so clearly. It’s been incredibly helpful!
@maryamblri
@maryamblri 9 ай бұрын
I have 8 years of experience in programming and I found this tutorial awesome. great job! please cover more design pattern like UOW and factory design pattern.
@Asp.net_Developer
@Asp.net_Developer 21 күн бұрын
Very informative and simplified context! ❤❣ I love this ...swear🤞 by next year march i will be finishing 2 years of experience in the work enviroment. so buying your courses is so neccessary for Juniours like me. I wish you can do Udemy curses, been searching for your courses on Udemy🙈
@vishalpathak832
@vishalpathak832 Ай бұрын
I guess in complex scenarios we should use generics to avoid this many entity repository and then implement Unit of work pattern on top of the generic repository.
@learndevtech
@learndevtech 3 ай бұрын
❤ magnific. This is way underrated!
@dmgj4946
@dmgj4946 Ай бұрын
Should you add another logic layer between controller and repository?
@赛尼木
@赛尼木 10 күн бұрын
pattern repository and unit of work
@usmanfarooq_dev
@usmanfarooq_dev Жыл бұрын
What will happen if we have a complex business transaction where we are saving multiple entities in DB. How would we manage the SaveChanges method when we need a db autogenerated id of one entity as an input value for another entity in same transaction?
@TheMezanine
@TheMezanine Жыл бұрын
In case of multiples transactions, you might implement Unit Of Work on top of Repositories. The UoW will manage the DBContext and implement transactions: EXAMPLE: public class UnitOfWork : IUnitOfWork { private readonly AppContext _context; public IUserRepository Users { get; private set; } public IAddressRepository Addresses { get; private set; } public UnitOfWork(AppContext context) { _context = context; Users = new UserRepository(_context); Addresses = new AddressRepository(_context); } public UnitOfWork() : this(new AppContext()) { } public int Save() { return _context.SaveChanges(); } public void Dispose() { _context.Dispose(); } public IDatabaseTransaction BeginTransaction() { return new EntityDatabaseTransaction(_context); } } USAGE: using(var unitOfWork = new UnitOfWork()) using(var transaction = new unitOfWork.BeginTransaction()) { try { unitOfWork.Users.Add(new User(... User One ...)) unitOfWork.Save(); unitOfWork.Addresses(new Address(... Address For User One ...)) unitOfWork.Save(); unitOfWork.Users.Add(new User(... User Two...)) unitOfWork.Save(); unitOfWork.Addresses(new Address(... Address For User Two...)) unitOfWork.Save(); transaction.Commit(); } catch(Exception) { transaction.Rollback(); } }
@gregorydeclercq2990
@gregorydeclercq2990 7 ай бұрын
If you use controller-service-repository and handle the logic in the service. You (should) never get those issues
@Lonchanick
@Lonchanick 10 ай бұрын
marvelous!
@luisgonzalez8877
@luisgonzalez8877 7 ай бұрын
Excellent explanation, thank you a million. I noticed that you invoked the repository tier from the controller (presentation) tier. Is this a best practice? I believe that specific logic requires the presence of business logic; for instance, in your example, it could be for the update method...
@HenningBerggren
@HenningBerggren 3 ай бұрын
You could insert an application layer (often referred as use case layer) where you would implement all your business logic (critical and application logic), but this is merely for larger applications.
@gregorydeclercq2990
@gregorydeclercq2990 7 ай бұрын
Are People using context in controllers?!
@kriskata7653
@kriskata7653 Жыл бұрын
Okay but what If we use services? I mean this repository pattern does the exact same thing as having a service. So I don't think this pattern makes sense in this case.
Using JSON IN C#! Serialization & Deserialization made easy!
14:47
tutorialsEU - C#
Рет қаралды 35 М.
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
Repository Pattern
11:08
Coding Concepts
Рет қаралды 69 М.
The Logging Everyone Should Be Using in .NET
15:34
Nick Chapsas
Рет қаралды 85 М.
C# Razor Pages - Complete Tutorial
25:20
tutorialsEU - C#
Рет қаралды 80 М.
Repository pattern in asp net core
14:50
kudvenkat
Рет қаралды 307 М.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 307 М.
Unit of Work in ASP.NET Core
14:57
Raw Coding
Рет қаралды 20 М.
CQRS & MediatR in a .NET 8 Web API 🚀
22:00
Patrick God
Рет қаралды 14 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 261 М.
Understand your C# queries! IEnumerable & IQueryable in explained
11:28
tutorialsEU - C#
Рет қаралды 39 М.
Master C# Interfaces in 12 Minutes - Beginner Tutorial
11:37
tutorialsEU - C#
Рет қаралды 24 М.
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН