First the difference between List<T>, IEnumerable<T> and IQueryable<T>.
The content of List<T> will always be loaded into memory, because it uses an array in the background.
This blog contains Azure, .Net, SQL & Full stack development concepts and code fixes.
First the difference between List<T>, IEnumerable<T> and IQueryable<T>.
The content of List<T> will always be loaded into memory, because it uses an array in the background.
The content of IEnumerable<T> will only load the requested item into the memory. Compiler sets up a state machine during compiling a method with IEnumerable<T> that has a yield return T. So only one item at a time will be loaded into memory in this case.
IQueryable<T> is "special" version of IEnumerable<T>. Specifically designed to query data sources, and implemented by data providers. Like EF, NHibernate. So when you tell EF to fetch the data with .ToListAsync<T>() EF will only then go the database and execute the generated query. See the docs for more info about IQueryable<T>.
1.Add Mapster packages from NuGet
2.Create Source class
3.Create Destination class
4.Create Service or repository class where mapping required to convert Dto to Enity object.
Simple Save and Retrieve example below for using mapster and entity framework.
Why Mapster over Auto mapper
| Method | Mean | StdDev | Error | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|
| 'Mapster 6.0.0' | 108.59 ms | 1.198 ms | 1.811 ms | 31000.0000 | - | - | 124.36 MB |
| 'Mapster 6.0.0 (Roslyn)' | 38.45 ms | 0.494 ms | 0.830 ms | 31142.8571 | - | - | 124.36 MB |
| 'Mapster 6.0.0 (FEC)' | 37.03 ms | 0.281 ms | 0.472 ms | 29642.8571 | - | - | 118.26 MB |
| 'Mapster 6.0.0 (Codegen)' | 34.16 ms | 0.209 ms | 0.316 ms | 31133.3333 | - | - | 124.36 MB |
| 'ExpressMapper 1.9.1' | 205.78 ms | 5.357 ms | 8.098 ms | 59000.0000 | - | - | 236.51 MB |
| 'AutoMapper 10.0.0' | 420.97 ms | 23.266 ms | 35.174 ms | 87000.0000 | - | - | 350.95 MB |
Azure Cosmo DB used to store non Sql data that is collection of objects.
Important key stack properties are id and partition key.
Partition Key is kind of grouping / or like disk drive C, D drive in our PC,Lap.
Make sure partition key as perfect column Ex: need to retrieve data frequently day wise means then i will make CreatedDate as partition key (CreatedDate= DateTime.UtcNow.Date)
id: its mandatory property & non-nullable
Unique/Primary key: will be combination of Partition Key + id
we can insert same id again but it's partition should be different. also, we can store different type of object but that object should contain same id and partition key.
Hierarchy: Example based OrderGroups is container
-->Data Base
|__ Container: kind of table or entity name
|__ Items: Kind of Table Entity values
|__Stored Procedure
|__User Defined Functions & Stored Procedure
|__ Triggers