๐๐ฌ๐ ๐จ๐ ๐๐ฌ๐๐จ๐๐ซ๐๐๐ค๐ข๐ง๐ : 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
๐๐ญ๐๐ฉ ๐ : The LINQ Query is processed by EF Core and build an representation that is processed by database provider, and the result is cached later on so we don't need to process it every time #dotnet
See thread ๐งตโฌ
๐๐ญ๐๐ฉ ๐ : The result is passed to the db provider and db provider identifies which parts of query can be evaluated in db, these parts are then translated into query language (e.g. SQL) after that translated query is sent to db and db returns results (but not entity instances)
๐๐ญ๐๐ฉ ๐ : For each item we check if it is tracking query EF checks the data in existing change tracker if found relevant entity is returned else new is created, its change tracking get set up and it is returned
For non tracking a new entity is always created and returned.
1๏ธโฃ Plain Text Password
Saving password in plain text is the worst approach because it is open to everyone who has database access and an easy target for attackers. Its not recommended at all.
2๏ธโฃ Hashed Password
Hashing the plain text password first and then saving it, it seems safe but it isnโt safe again, you can fall for attack in this case as well rainbow attack.
โ๏ธIf you like my tweets, please join 400+ Software Engineers to receive an actionable tip weekly in your inbox through my Newsletter.(lnkd.in/d69Va5CM)
โ Use an overload of theย String.Equalsย method to test whether two strings are equal
โ Use theย String.Compareย andย String.CompareToย methods to sort strings, not to check for equality.
โ Use overloads that explicitly specify the string comparison rules for string operations. Typically, this involves calling a method overload that has a parameter of typeย StringComparison.
GET is used to retrieve data, POST is used to save, PUT is used to update existing data edit is common example of it, PATCH is lighter version of PUT , it is used to update just a specific information instead of updating all data on server DELETE is used to remove records.
In CRUD operations
C stands for create : POST
R stands for read : GET
U stands for update : PUT/PATCH
D stands for delete : DELETE