https://github.com/nisanurbulut/shilla
https://github.com/nisanurbulut/shilla
automapper-profiles dotnetcore efcore swagger
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nisanurbulut/shilla
- Owner: NisanurBulut
- Created: 2023-08-20T17:34:20.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-16T20:54:53.000Z (over 1 year ago)
- Last Synced: 2025-02-03T22:40:46.782Z (4 months ago)
- Topics: automapper-profiles, dotnetcore, efcore, swagger
- Language: HTML
- Homepage:
- Size: 22 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
# Magic Shilla App 📌❤ I have missed the code Net core
## Give a Star! :star:
If you like or are using this project to learn or start your solution, please give it a star. Thanks!



### Technical Dictionary
🧨 Binding Parameters in Asp.Net MVC
- FromQuery :
This type contains query items. To use them, we need to read parameters
from URL address and we need to check ? character.
Example https://example.com/api/products?id=123&name=keyboard```C#
[HttpGet("products")]
public IActionResult GetProduct([FromQuery] int id, [FromQuery] string name)
{}
```- FromBody :
This type uses data inside of HTTP Body. it generally used for POST, PUT or PATCH requests.
Kind of data might be JSON, XML or another type.```C#
[HttpPost("products")]
public IActionResult CreateProduct([FromBody] ProductDto productDto)
{
}
```- FromRoute :
It is used to bind routing parameters in the URL to a parameter in the API method. Redirect parameters are dynamic values specified in a specific part of the URL.
Example https://example.com/api/products/{id} It is commonly used when reading resource id information.```C#
[HttpGet("products/{id}")]
public IActionResult GetProductById([FromRoute] int id)
{
}
```🧨 Validation

🧨 Region Directive
I am particularly fond of 😻 the
#region
directive. It allows us to collapse code in a customized manor.
Regions are created in this format,```C#
#region NisanurStartedCoding
return Ok(👌);
#endregion
```
Benefits of using region director :
- Well organized
- easily readable
- code can be easily navigated
- increade efficiency
### Dapper vs Entity FrameWork

### IEnumerable vs IQueryable

🧨 Differences Between Scoped, Transient, And Singleton Service
Why we require
- It defines the lifetime of object creation or a registration in the .net core with the help of Dependency Injection.
- The DI Container has to decide whether to return a new object of the service or consume an existing instance.
- The lifetime of the Service depends on how we instantiate the dependency.
- We define the lifetime when we register the service.
Three types of lifetime and registration options
- Scoped
- Transient
- Singleton
Scoped
- In this service, with every HTTP request, we get a new instance.
- The same instance is provided for the entire scope of that request.
- eg., if we have a couple of parameter in the controller, both object contains the same instance across the request
- This is a better option when you want to maintain a state within a request.
Transient
- A new service instance is created for each object in the HTTP request.
- This is a good approach for the multithreading approach because both objects are independent of one another.
- The instance is created every time they will use more memory and resources and can have a negative impact on performance
- Utilize for the lightweight service with little or no state.
Singleton
- Only one service instance was created throughout the lifetime.
- Reused the same instance in future, wherever the service is required
- Since it's a single lifetime service creation, memory leaks in these services will build up over time.
- Also, it has memory efficient as they are created once reused everywhere.
When to use which Service
Singleton approach => We can use this for logging service, feature flag(to on and off module while deployment), and email service
Scoped approach => This is a better option when you want to maintain a state within a request.
Transient approach => Use this approach for the lightweight service with little or no state.
🔍 AsNoTracking:
in scenarios where you only need read-only access to data and don't intend to modify or update it,
using AsNoTracking can offer performance benefits.
💡 It avoids the overhead of change tracking, resulting in faster query execution.
🔍 AsNoTrackingWithIdentity:
When using AsNoTrackingWithIdentity, EF Core still tracks the identity of entities retrieved from the database.
💡 It is particularly useful when working with scenarios that require a mix of read-only and update operations
📌 Key Differences:
- AsNoTracking completely disables change tracking, resulting in improved performance for read-only scenarios
- AsNoTrackingWithIdentity disables change tracking for most properties, but it keeps track of the entity's identity,
allowing updates to be applied efficiently when necessary.
🔧 When to Use Which ❓ when should you use each method ❓
-
Use AsNoTracking when you only require read-only access to entities and want to optimize performance. - Use AsNoTrackingWithIdentity when you need both read-only access and the ability to update specific entities efficiently.
Data Transfer Objects are used to transfer data between the Application Layer and the Presentation Layer.
#### 💡 Layouts
Layout actually used to maintain consistency in the web pages and also using this, repetitive code can be reduced. Normally, layout mainly contains header, navigation, menu elements or footer sections.
#### 💡 Partial Views
Partial views mainly reduce code duplicate by maintain reusable parts of the views.
#### 💡 View Components
It is quite similar to the partial view in terms of reusability and reduce code repetition.
- View components do not use model binding
- View Component class must be derived from the ViewComponent class.
- Like Partial View, View components does not depend on controllers. It has its own class to implement the logic to develop the component’s model and razor markup view page.
- View Components can utilize dependency injection
Actually, views help us to establish a SOC Design (Separation of Concerns) within the MVC application.
It basically separates the user interface from other parts of the application.
Packages
Links
References
-
[Microsoft.AspNetCore.JsonPatch](https://www.nuget.org/packages/Microsoft.AspNetCore.JsonPatch/7.0.10)
-
[Microsoft.AspNetCore.Mvc.NewtonsoftJson](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.NewtonsoftJson/7.0.10)
-
[Serilog.AspNetCore](https://www.nuget.org/packages/Serilog.AspNetCore/7.0.0)
-
[Serilog.Sinks.File](https://www.nuget.org/packages/Serilog.Sinks.File/5.0.0)
-
[Microsoft.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/7.0.10)
-
[Microsoft.EntityFrameworkCore.Tools](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/7.0.10)
-
[AutoMapper.Extensions.Microsoft.DependencyInjection](https://www.nuget.org/packages/AutoMapper.Extensions.Microsoft.DependencyInjection/12.0.1)
-
[AutoMapper](https://www.nuget.org/packages/AutoMapper/12.0.1)
-
[Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer/5.1.0](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer/5.1.0/)
-
[Microsoft.AspNetCore.Identity.EntityFrameworkCore](https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.EntityFrameworkCore/7.0.0-preview.5.22303.8)
-
[What is JSON Patch?](https://jsonpatch.com/)
-
[Generate Fake C# Data](https://generatedata.com/generator)
-
[10-bad-practices-to-avoid-in-aspnet-core-api-controllers](https://dev.to/andytechdev/10-bad-practices-to-avoid-in-aspnet-core-api-controllers-2o9l)
-
[differences-between-scoped-transient-and-singleton-service](https://www.c-sharpcorner.com/article/differences-between-scoped-transient-and-singleton-service/)
-
[explaining-difference-between-asnotracking-net-core](https://www.linkedin.com/pulse/explaining-difference-between-asnotracking-net-core-ahad-tagh%C4%B1yev/)
-
[Data-Transfer-Objects](https://aspnetboilerplate.com/Pages/Documents/Data-Transfer-Objects)
-
[Dapper v/s Entity Framework(Core)](https://www.youtube.com/watch?v=ialFGpKD8yI)
-
[IEnumerable vs IQueryable](https://www.youtube.com/watch?v=J2u1DmnE9mU)
-
[Udemy Course RESTful Web API - The Complete Guide (.NET7 API) Part 1](https://www.udemy.com/course/restful-api-with-asp-dot-net-core-web-api/)
Architecture Patterns
Speed Up API Performance Methods
### Swagger Documentation
