Тёмный

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

tutorialsEU - C#
Подписаться 21 тыс.
Просмотров 10 тыс.
50% 1

🔥 Learn how to use the C# Repository Design Pattern! You will love it!
🚀 C# Progress Academy - Become a job-ready C# and Angular web developer to land your dream developer role: bit.ly/45vbPUg
Here is the article: tutorials.eu/how-to-send-emai...
We'll make sure to turn you into a true developer in no time!
TIMESTAMPS
00:00 Intro
00:25 Presentation of the repository pattern
03:19 This one is for you
03:52 Implementation of the c# repository pattern
17:58 Thanks for watching!
So, what is C#?
C# (pronounced "See Sharp") is a modern, object-oriented, and type-safe programming language. C# enables developers to build many types of secure and robust applications that run in .NET. C# has its roots in the C family of languages and will be immediately familiar to C, C++, Java, and JavaScript programmers. This tour provides an overview of the major components of the language in C# 8 and earlier. If you want to explore the language through interactive examples, try the introduction to C# tutorials.
And what is ASP.NET?
ASP.NET is an open-source, server-side web-application framework designed for web development to produce dynamic web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, applications and services. The name stands for Active Server Pages Network Enabled Technologies.
And what is the Repository Design Pattern, then?
The Repository Design Pattern in C# Mediates between the domain and the data mapping layers using a collection-like interface for accessing the domain objects. The Repository design pattern allows programmers to maintain their code more effectively.
To learn more, make sure to watch the video, and we promise you that you'll become a C# developer by the end of the course! Have fun!
#csharp #coding #tutorial #learn #microsoft #net #repository #designpatterns #designpattern #aspnet
TAGS
Tutorials,Tutorial,Programming,Course,Learn,Step by step,guide,development,programmer,video course,video tutorial,learn how to,how to,c#,.net,.net core,dotnet,core,code,asp,asp net,c sharp,coding,csharp,asp.net core,asp.net,programming,design patterns,design pattern,repository pattern,repository,design patterns c#,c# repository design patterns,repository design pattern,repository pattern in asp.net core,repository pattern c#,repository pattern in mvc
tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
Stay tuned and subscribe to tutorialsEU: goo.gl/rBFh3x
C#: / @tutorialseuc
Facebook: / tutorialseu-1093802040...
LinkedIn: / tutorialseu
Discord: / discord

Опубликовано:

 

4 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 10   
@tutorialsEUC
@tutorialsEUC Год назад
🚀 C# Progress Academy - Become a job-ready C# and Angular web developer to land your dream developer role: bit.ly/45vbPUg
@maryamblri
@maryamblri 4 месяца назад
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.
@luisgonzalez8877
@luisgonzalez8877 2 месяца назад
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...
@usmanfarooq3071
@usmanfarooq3071 Год назад
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 2 месяца назад
If you use controller-service-repository and handle the logic in the service. You (should) never get those issues
@Lonchanick
@Lonchanick 5 месяцев назад
marvelous!
@gregorydeclercq2990
@gregorydeclercq2990 2 месяца назад
Are People using context in controllers?!
@kriskata7653
@kriskata7653 8 месяцев назад
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.
Далее
Singleton Design Pattern in C# - Do it THAT way
13:15
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 251 тыс.
ASP.NET Core Crash Course - C# App in One Hour
1:00:44
Просмотров 1,5 млн
Brutally honest advice for new .NET Web Developers
7:19
Generic Repository Pattern c#
17:35
Просмотров 18 тыс.
Repository Pattern
11:08
Просмотров 66 тыс.
Repository pattern in asp net core
14:50
Просмотров 299 тыс.
Unit of Work in ASP.NET Core
14:57
Просмотров 18 тыс.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27