๐๐ฌ๐ ๐จ๐ ๐๐ฌ๐๐จ๐๐ซ๐๐๐ค๐ข๐ง๐ : For read only queries e.g. (GetAll,GetById etc.) use AsNoTracking , when we use it entities are not tracked for change so it brings data more speedily. #dotnet
See thread ๐งต๐ฝ
๐๐ง๐๐ฅ๐ฎ๐๐ ๐ง๐๐๐๐ฌ๐ฌ๐๐ซ๐ฒ ๐๐ง๐ญ๐ข๐ญ๐ข๐๐ฌ ๐๐ง๐ ๐๐จ๐ฅ๐ฎ๐ฆ๐ง๐ฌ : While retrieving data from multiple table make sure to include only necessary tables and columns Use eager loading only when it is necessary. #dotnet
๐ ๐จ๐ซ ๐ฅ๐๐ซ๐ ๐ ๐๐๐ญ๐ ๐ฎ๐ฌ๐ ๐๐ค๐ข๐ฉ ๐๐ง๐ ๐๐๐ค๐ : Use skip and take to retrieve data from table for large collections because if we try to bring all data in single try it can take time that will give bad user experience takes next values. #dotnet
๐๐ฌ๐ ๐๐ฌ๐ฒ๐ง๐ ๐ฆ๐๐ญ๐ก๐จ๐๐ฌ : For better user experience use async methods e.g. FirstOrDefaultAsync , SingleOrDefaultAsync and ToListAsync. #dotnet
๐๐๐๐ฎ๐๐ ๐๐ซ๐ข๐ฉ๐ฌ ๐ญ๐จ ๐๐๐ญ๐๐๐๐ฌ๐ : Use bulk operations available for SAVE/DELETE operations instead of iterating one by one it will reduce trips to database. After that only write one line await _context.SaveChangesAsync(); to reflect changes over database. #dotnet
๐๐ฌ๐ ๐๐ซ๐ฒ๐๐๐ญ๐๐จ๐ง๐๐ง๐ฎ๐ฆ๐๐ซ๐๐ญ๐๐๐๐จ๐ฎ๐ง๐ญ : For large of data we use pagination and it is displayed on basis of total records. Use TryGetNonEnumeratedCount instead of count it attempts to determine the number of elements in a sequence without forcing an enumeration
๐๐ฌ๐ ๐๐๐ฎ๐๐ซ๐ฒ๐๐๐ฅ๐ : For long and condition based filters use IQueryable,it executes queries on the server side.After all conditions we can use ToList to fetch data it makes query faster as we are first creating complete query and then we are bringing the data #dotnet
๐ง If you like it join family of 550+ Software Engineers via my Newsletter : lnkd.in/dNHxJGRG
It is software assembled into an app pipeline to handle requests and responses. In simple, it gives us the facility to add additional logic before and after the HTTP request.
What is SOLID , why we need these principles and S explained ?
It is combination of 5 design principles
S - Single Responsibility Principle (SRP)
O - Open/Closed Principle (ORP)
L - Liskov Substitution Principle (LSP)
I - Interface Segregation Principle (ISP)
Thread ๐งต๐
D - Dependency Inversion Principle (DIP)
Why we need SOLID or its benefits
- Better Testability
- Reduces coupling
- Removes Duplication
- Increases Readability
- Increases Extensibility
SRP says :-
- A class/method should have one reason to change
- A class/method should have only one responsibility
- A class/method should be related to a single purpose
With SRP we achieve :-
- Class/method becomes smaller and cleaner
- Now in future updating the code becomes easier
4) TimeZoneInfo, used in .NET, relies on Windows time zone IDs, which may differ from widely used Olson (tz) identifiers
5) Unfortunately humanity didโ not agree on single calendar (Gregorian, Julian, Coptic and Buddhist) , NodaTime covers this space which default lacks
๐Read these 15 awesome topics of .NET via my Newsletter.
Join 3400+ : for upcoming issues.
EP 14: 7 Awesome Features of C# (10)
EP 13: Bogus - A Fake Data Generation
EP 12: Global Exception Handling
EP 11: Default vs Autofac DI Container
EP 10: Actionโฆ https://t.co/62ug4BOMVBlnkd.in/dNHxJGRG twitter.com/i/web/status/1โฆ
- Properties are first class citizens in C#
- We used properties to achieve abstraction
- Properties are implemented via accessors
- Enable developers to write code that accurately expresses their design intent #dotnet
Read only Properties
- Serve the purpose of getters
- Use them for retrieving the information in DTO
- We can not set them