- 41
- 117 011
Saeed Esmaeelinejad
United Kingdom
เข้าร่วมเมื่อ 20 ส.ค. 2021
Hey there, I'm Saeed and this is my TH-cam channel. Here I try to help you be a deeper .NET developer.
🔥 xUnit version 3 is out: they finally healed the pain!
xUnit.v3 has been released recently with lots of cool features, In this video I've covered three of the most interesting of them.
⭐ Check the code [xUnitV3Features]: github.com/sa-es-ir/youtube-samples?tab=readme-ov-file#content-list-order-by-date-desc
xUnit migrations: xunit.net/docs/getting-started/v3/migration
Moments
00:00 - Intro
00:32 - xUnit structure
02:06 - Running tests in sequence or parallel
05:43 - IClassFixture in xUnit
11:23 - ICollectionFixture in xUnit
#dotnet #csharp #unittesting #xunit #xunitv3
-------------------------------------------
👉 Follow me on LinkedIn:
www.linkedin.com/in/sa-es-ir
⭐ Check the code [xUnitV3Features]: github.com/sa-es-ir/youtube-samples?tab=readme-ov-file#content-list-order-by-date-desc
xUnit migrations: xunit.net/docs/getting-started/v3/migration
Moments
00:00 - Intro
00:32 - xUnit structure
02:06 - Running tests in sequence or parallel
05:43 - IClassFixture in xUnit
11:23 - ICollectionFixture in xUnit
#dotnet #csharp #unittesting #xunit #xunitv3
-------------------------------------------
👉 Follow me on LinkedIn:
www.linkedin.com/in/sa-es-ir
มุมมอง: 25
วีดีโอ
xUnit Essentials: Test parallelism, Collections and Fixtures!
มุมมอง 1527 ชั่วโมงที่ผ่านมา
xUnit Essentials: Test parallelism, Collections and Fixtures In this video, I walk through the xUnit fundamentals that every developer should know about, you can find the answers to these questions in the video: - How will xUnit pick and run a test? - When will tests be run in sequence or in parallel? - What is a collection? - How/When should I use IClassFixture and ICollectionFixture? ⭐ Repo [...
👉 Implement a Kafka-like message broker with .NET BlockingCollection!
มุมมอง 10K2 หลายเดือนก่อน
In this video, we'll see how easy implementing a Kafka-like message broker is. The purpose is to detach consuming from producing messages. I've implemented three methods: Produce, Consume, and Close. Please let me know your feedback in the comments. ⭐ Check the code [KafkaWithBlockingCollection]: github.com/sa-es-ir/youtube-samples/tree/main?tab=readme-ov-file#content-list-order-by-date-desc Mo...
🐞 EF Core bug: Avoid using Async method with Large data result!
มุมมอง 13K3 หลายเดือนก่อน
There is a bug in the EF Core Async methods! Optimized queries are not enough when we deal with large data and other factors come into the picture like network or EF Core internals. In this video, I've explained a bug in Async methods which is surprising since always using asynchronous is recommended but it seems here is not true yet! ⭐ Check the code [EFCoreLargeData]: github.com/sa-es-ir/yout...
🥶 Managing Concurrency with SemaphoreSlim: Avoid DeadLock!
มุมมอง 7043 หลายเดือนก่อน
In this video, I show you my real experience with fixing a deadlock in a high-load application which was using SemaphoreSlim. I've covered some caveats in using SemaphoreSlim and CancellationToken which can put your application in a deadlock situation. 👉 Checkout the repo [SemaphoreSlimWithCancellationToken]: github.com/sa-es-ir/youtube-samples/tree/main?tab=readme-ov-file#all-youtube-sample-co...
🔥 Don't use Task.WhenAll, it may not be efficient enough!
มุมมอง 7K4 หลายเดือนก่อน
In C#, Task.WhenAll is commonly used to run multiple tasks in parallel, but is it always the best option? In this video, I'll explore scenarios where Task.WhenAll may not be the most efficient choice. I'll also demonstrate how to create a custom method for executing tasks in parallel, avoiding the pitfalls of Task.WhenAll. Check the code[RunMultipleTasks]: github.com/sa-es-ir/youtube-samples/tr...
Integration Test: Mock PartOf a class
มุมมอง 2344 หลายเดือนก่อน
When we're trying to write integration tests, usually it's better not to mock any class or method and execute actual code. By doing so we can make sure all code paths and different scenarios will be covered. But what if you want to mock only one method of a class? Well, there are a few ways to do that, in this video, while I talk about all possible ways the main focus is on NSubstitute and how ...
🍕 Template Method pattern: Refactor and make your application plug-in-able
มุมมอง 6985 หลายเดือนก่อน
Template Method is one of the behavioral patterns which means you can manage the code to behave differently based on our logic. It is used to define a skeleton of an algorithm in a base class and other subset classes can follow the steps or even customize them. In this video, I'm going to refactor a code and use the Template Method pattern. Check the code [TemplateMethod]: github.com/sa-es-ir/y...
🌵 Can Async/Await block the main thread?
มุมมอง 1.6K5 หลายเดือนก่อน
In this video, I show how to use async/await pattern in the correct and prevent the main thread from being blocked. Check the repo: github.com/sa-es-ir/youtube-samples/tree/main?tab=readme-ov-file#all-youtube-sample-codes-i-use-in-my-channel #asyncawait #csharp #dotnet #asynchronousprogramming #async Moments 00:00 - Intro 00:15 - async/await diagram 02:16 - The code part of async/await 04:58 - ...
🔐 ASP.NET Core Authorization: Policy Based Access Control
มุมมอง 9486 หลายเดือนก่อน
In this video, I show you how to implement Policy-Based Authorization in ASP.NET Core, I covered both minimal API and Controller-Action. Check the code here: Repo: [PolicyBasedAuthorization] github.com/sa-es-ir/youtube-samples?tab=readme-ov-file#all-youtube-sample-codes-i-use-in-my-channel #aspnetcore #dotnet #authorization #policybasedauthorization Moments 00:00 - Intro 00:27 - The code base 0...
🔐 ASP.NET Core Authorization: Role-Based Access Control (RBAC)
มุมมอง 1.6K7 หลายเดือนก่อน
In this video, I show you how to implement Authorization using Role-Based Access Control (RBAC), I covered both minimal API and Controller-Action. Check the code here: Repo: [RoleBasedAuthorization] github.com/sa-es-ir/youtube-samples?tab=readme-ov-file#all-youtube-sample-codes-i-use-in-my-channel Moments 00:00 - Intro 00:47 - The code base 02:35 - Call the API 03:05 - Generate JWT token using ...
🌶️ How to use Kafka in .NET 8?
มุมมอง 8K7 หลายเดือนก่อน
Do you want to know how we can use Kafka in .NET? Then here you go! In this video, I've tried to simplify concepts about Kafka and also write a semi-real-world application that you may face in your daily projects. repo[KafkaDotNet]: github.com/sa-es-ir/youtube-samples?tab=readme-ov-file#all-youtube-sample-codes-i-use-in-my-channel I think event-steaming is a really nice area to investigate and ...
🚀 EF Core 8: How to optimize a query?
มุมมอง 3.5K7 หลายเดือนก่อน
Do you want to make your queries more performant and efficient? Then this is the way you go! I've tried to address most cases in a Real-world query that you may face in your projects and fix them. If you saw my previous videos, I always like to explain the current situation and how to make it better, and finally code, I believe you grasp the concept better. Hope you enjoy it! Repo[EFQueryOptimi...
Writing your own MediatR from scratch in C#
มุมมอง 1.1K8 หลายเดือนก่อน
I think most .NET developers already use or at least know about the MediatR Nuget package. It's an in-process messaging with no dependencies and supports request/response, commands, and notifications. Really cool Nuget library. But have you thought about how MediatR works? As I'm curious to know how things work, here I try to show the gist of MediatR and how to write your own one from scratch i...
Multi-Tenant applications: How to do it in the correct way!
มุมมอง 2.8K9 หลายเดือนก่อน
Multi-tenancy allows multiple users to share resources while keeping their data separate. In a multi-tenant application, customization is provided for each user group (tenants), while the core functionality remains the same. How we should handle this situation? well, it's easy! Just need to know, the current request is for which tenant, done! In this video, I've tried to address two issues that...
💥 gRPC on .NET: How to use gRPC in ASP.NET Core Api
มุมมอง 6K10 หลายเดือนก่อน
💥 gRPC on .NET: How to use gRPC in ASP.NET Core Api
🚀 ASP.NET Core: Faster Api with Multi-Layer cache!
มุมมอง 1.4K10 หลายเดือนก่อน
🚀 ASP.NET Core: Faster Api with Multi-Layer cache!
.NET Aspire: How to use Redis step by step
มุมมอง 89710 หลายเดือนก่อน
.NET Aspire: How to use Redis step by step
🌶️ .NET: What is wrong with the HttpClient object?
มุมมอง 2.4K11 หลายเดือนก่อน
🌶️ .NET: What is wrong with the HttpClient object?
SQL Server Indexing: How database engine chooses an index for a query?
มุมมอง 57011 หลายเดือนก่อน
SQL Server Indexing: How database engine chooses an index for a query?
.NET Aspire: How to use RabbitMQ component step by step?
มุมมอง 2.7Kปีที่แล้ว
.NET Aspire: How to use RabbitMQ component step by step?
🔐 ASP.NET Core Authentication: JWT token validation using OpenID Connect (OIDC)
มุมมอง 9Kปีที่แล้ว
🔐 ASP.NET Core Authentication: JWT token validation using OpenID Connect (OIDC)
🆒️ .NET Aspire: How it works behind the scenes?
มุมมอง 4.3Kปีที่แล้ว
🆒️ .NET Aspire: How it works behind the scenes?
What is the difference between BackgroundService and HostedService?
มุมมอง 4.4Kปีที่แล้ว
What is the difference between BackgroundService and HostedService?
🔆 C# Serializers: NewtonSoft vs Protobuf vs Apache.Avro vs MessagePack vs Bson
มุมมอง 2.2Kปีที่แล้ว
🔆 C# Serializers: NewtonSoft vs Protobuf vs Apache.Avro vs MessagePack vs Bson
EF Core: Be careful about Find method cache!
มุมมอง 397ปีที่แล้ว
EF Core: Be careful about Find method cache!
❌️ ASP.NET Dependency Injection: You may be wrong about Scoped services!
มุมมอง 3.2Kปีที่แล้ว
❌️ ASP.NET Dependency Injection: You may be wrong about Scoped services!
♾️ ASP.NET Dependency Injection: Handle multiple implementations for one interface with delegate
มุมมอง 4.3Kปีที่แล้ว
♾️ ASP.NET Dependency Injection: Handle multiple implementations for one interface with delegate
👨💻 C# xUnit: How to run code before and after a test!
มุมมอง 954ปีที่แล้ว
👨💻 C# xUnit: How to run code before and after a test!
موفق باشی بسیار عالی
ممنون باباجان❤️
Thanks man, helped a LOT. Happy Holidays
Glad it was helpful, enjoy holidays:)
Hi , I have requirement using Cosmos Db.All tenants share same dbnsme and connection string Which is better to have 1.Single Dbcontext Change the container name on dynamic based on tenant provider 2. Spreate Dbcontex for each tenant..
I'll go for the first approach, the important thing here having a single connection to cosmosdb, it is exactly like calling a third-party API, you'll create a HttpClient with a base address (here is the connecitonString) and call different endpoints (here is the containername).
@sa-es-ir Thank you for the details.. But I have one query, I have created a project with 1st approach 1., In a single AppDbcontext Onmodelcreating calling only once 2. When I send a request for another tenant Onmodelcreating is not getting called.. 3.Using AddDbContextFactory in Di container Please let me know to resolve this
@@ArjunRR-cz8hb Do you have a code like mine in this video? if yes then please provide a github repo then I can see the code and talking about the actual problem.
Nice topic
Glad you like.
Well explained. Thanks.
Glad it was helpful!
Awesome explanation, great job!
Glad it was helpful!
great way to explain! Thanks, one question in my mind - After updating database to the last sate and removing migration, you still have that Description property, so we have to remove our code level changes manually, right?
Yes, correct. Basically we need to do two steps: 1- cleanup migrations and database (this video) 2- remove the properties that already cleaned up in previois step from the code
Hi dear fellow, how yo doing?! I hope pretty good ❤ well first of all thanks a bunch for your teaching here.
I'm pretty good, thanks:) Glad you like the video
بعضی از تلفظات خیلی فارسیه،حیفه متد، ریسپانس و ... که بیشتر تو محیط های آیتی انقدر اشباه تلفظ میشه که تلفظ اشتباهش فسیل شده.
ممنون از اینکه با دقت ویدیو رو تماشا میکنی! هر کشوری لهجه خودشو داره اگر تو محیط انیترنشنال کار کرده باشی به راحتی متوجه لهجه انگلیسی حرف زدن هندی ها، فرانسوی ها(وحشتناک)، روسی ها و.... کاملا طبیعی هست!
@@sa-es-ir منظورم لهجه نیست ،تلفظه.
It's weird that still open
They mentioned in the ticket that it will take years to fix!!
Why not use Channel?
While using Channels is ok for doing the same purpose, I find it more complicated to work with. Basically, I always like the visibility in the code, no magic behind the scene happening.
❤❤ nice
Thanks! I'm glad you liked it.
Great topic as always, explaining complex topics in the most simplest way ❤️ I think we can also enumerate the Blocking collection in the Consume method and yield the Item back since Blocking Collection waits for new items and in close method we give the "Complete" to the blocking collection
Glad you like the video and awesome suggestion about using yield, I didn't think about this option, thank you for the input.
اولین کامنت 😅 سامانه استعلام یکپارچه
محسن این سامانه استعلام یکپارچه دیگه بخشی از خاطرات ماندگار منو تو شده:)))
Excellent! It helped me a lot!!
Glad you enjoyed:)
Very well explained. Simplicity at at its best.
Happy you like the video
Thank you very much for your videos.
You are very welcome
Hello @Saeed, at 16:32 you said, if we make changes in proto file and if API is referring it directly, then it will break API. So, it will not impact if sdk referring to same proto file (if proto file changes and bulid)?
Well in the video I created a decorator on top of the `Generated` grpc service in the SDK, so basically API depends on the SDK (the decorator service), what we want is not depend on any generated grpc classes from the caller side (the API). If there are some changes on the GRPC server and there is some direct dependencies to it then all those clients will be failed but if inside the sdk decorator we handle all the exceptions then we are safe from breaking those callers, at least until we change the SDK!
@@sa-es-ir sounds good. I got your point. :) thank you
Thank you so much! What about synchronization between application instances. Do you have any solution for this?
The best way is using a message queue, so one instance will send a message and the other side there is a consumer listening on same queue to process and sync the state.
Muito bom conteúdo.
Thank you:)
Great work Saseed! You are explaining the exact scenario what we faced. As you mentioned We never aware of this problem. You taught me not only how to use nvarchar with EF, we should always keep an eye on the all bugs and discussion in the repo. Thanks again and keep doing the great work. 👍
Very happy it was helpful to you, please support me by sharing my videos to your network, would be appreciated 🙏
@@sa-es-ir I already shared to my network. 👍
nice tip for ef core but don't use database for storing big file , SQL server design for fast and small request/response . file stream is good option for storing that as binary , also there is azurite (Azure Storage API) for free write on node.js . you can use that as well . tip: as much as you can don'tuse max on varchar or nvarchar .always have limit . nice work keep going.
@@mahdiyar6725 Thanks for the great sum up and totally agree.
Great work Saeed, keep continue 🙂
@@SamH-h1v Thanks and happy you like it
This video was very helpful, but is there any chance you know why I get the error " Connect to ipv4#127.0.0.1:9092 failed: Unknown error (after 2032ms in state CONNECT)" with both the producer and consumer? Thanks!
Thank you and happy it was helpful. About the error, please follow the code in my repo the link is in the description, better to use localhost:9092 and make sure both Kafka and zookeeper are using same network.
@@sa-es-ir But that's what I'm doing. Is it possible that my error comes from not using docker?
@@cvetomiranedelcheva9946 Are you run kafka and zookeeper both? they have access to call each other? I think better to run in docker to make sure the problem is not in your code
@@sa-es-ir Okay, thank you very much!!
Greate! thanks Saeed. how if we have many DoNothing(). are we should put Yield as many method as we called? the second, how process long running sub method as background proses?
Glad you like the video, you can use Task.Yield as many as you can, no issue with that but better to use it when needed to avoid extra overhead for runtime. I didn't get the second question, can you explain more.
Thank you, very useful tips you have shared here ❤
Glad it was helpful!
Thank you for your useful tips
Happy you like it
Great content
Glad you like it 🙏
Hi Saeed, could you creating video about keycloak?
I didn't use it in a production project, I'll check it.
Hi saeed, thanks for great explanation with short duration. I want to ask, how if the consumer fails saving data because maybe there's any field required(consumer side) but the not provided by producer.
Good question, the Consumer needs to tell kafka to commit the message, either auto-commit by kafka lib or manually commit by developer, the point is you need to handle the validation on consumer so if there is a invalid message you just skip that message and commit it without processing.
Try Apache.Avro without the ReflectReader/Writer. That one is significantly slower than the SpecificReader/Writer since it uses a ton of reflection.
Nice point and thanks for that, I'll check it later.
Beautifully described bro. Loved the explanation 😇
Glad you like it, thanks
thank you saeed 👌🏻
Thank you
this channel is pure gold
Much appreciate the support, please help me by sharing my video with your friends.
Woww❤ about to implement this in my project. This provides a good aspect that I’ve never thought of. Thank you Saeed 😊
I appreciate Jan, please help me by sharing my video with your friends.
Thank you Saeed I enjoyed your explanation
Glad you enjoy it.
Good tutorial!
Thank you
I think a video on MessagePack would be awesome 👀I don't think anyone has made one for that library yet!
Thanks for the suggestion, I'll put it in the list
using Select to query a subset of columns is what I'd love to do, but my query is quite complex with a number of layers of Include/ThenInclude. When I try to use this technique just on the top level table I get runtime errors with the data in joined tables. For example, the model generated database-first has both a Foreignkeyid property and Childentity property. If I select the Foreignkeyid field, it does not know how to bring in the Childentity model. In your example you have a Dto record which I presume is a more flattened representation of the Employee model. You reference a child entity property x.User.UserName. In my case I want the x.User. And probably some child entity of x.User as well. I haven't seen great examples of optimizing columns selected by EF queries (or in my case EF Core). There are only really simple cases being demoed.
You got the main idea about having required columns only, if you have time to create a simple repo about what you need then we can fix it together, I'd would say it is easy to tell EF core to generate what we want.
@@sa-es-ir Thanks for the reply. I was able to work out the syntax to get what I want in the long run. However, I am now realizing that if you try to include more than one child MANY relationship, performance tanks noticeably. I am aware of the Split() function, but I've come to the conclusion it's just better for me to run multiple queries rather than one or two big complex queries.
I might missed something here. How did you get the token in the first place before you call the getweather?
I generated the token from auth0.com for my user, basically, I didn't want to cover token generation in this video and I've tried to show how to `validate` that token, no matter where it comes from.
Change the order of tasks in the final list to "new List<Task> { taskThree, taskTwo, taskOne }" to see why it doesn't work the way you want it to. It will wait for three seconds before it cancels the "CancelationToken".
Yes, it can be improving by dequeueing waiting each task via WaitAny mutiple times, but it can increase memory and CPU allocation.
In the worst case, it just behaves like Task.WhenAll()!
@@sa-es-ir U didnt get what he want to say, it is not about worst case, it is about reordering await affects execution time in you approach, if last task will wait 1 sec before exeption, you still will wait 3 sec because of first task 3 sec delay
@@igormelnikov5166 Yes your scenario is perfectly fine and can happen because there is no way to know task priorities, my point is, even in worst case (taking 3 sec) is the same Task.WhenAll which always takes 3 sec. Am I correct?
@@sa-es-ir There is a way to respect task priorities, read my first comment. Worst cases are same in all soulutions ofcourse. But in average solutions have different time
Awesome explanation
Glad you like it, I would appreciate it if you share this video on your network🙏
Great!
Glad you like it, I would appreciate it if you share this video on your network🙏
Thank you for the content ❤
Glad you like it, I would appreciate it if you share this video on your network🙏
There is a new Task.`WhenEach` static method in .NET 9
Please make a separate video on execution plan in detail. Thanks in advance
Noted with thanks, stay tunned.
❤❤❤❤❤❤❤❤❤❤❤
Thank you baba♥
could be explained under 5minutes. Stupid m o ha mmads content, fkin cancer
Perfect
Thank you