Tagged articles
Image from Pexels

Tagged articles - Dependency Injection

Found 11 articles tagged with Dependency Injection

Running multiple queries at the same time in EF Core
Overcoming the limitation of EF Core query execution
 
0
Since the time of ADO in .NET one of the limitations was that one connection can execute single command at the time. Same limitation Entity Framework inherited and you can execute single command at the time per instance of your DbContext...read more
Mocking System.IO filesystem in unit tests in ASP.NET Core
Testable filesystem operations in ASP.NET Core and C#
0
Working with file system operations like creating or deleting files and directories if quite often part of applications flow. Both .NET and .NET Core come with great out of the box classes and methods to achieve this. These classes and methods are part of System.IO name space, but unfortunately both .NET and .NET Core implementations are the same and they use static classes and method to manipulate files and directories on the host file system. ...read more
Using options pattern in MVC5 legacy applications with web.config
Simple implementation of options pattern in .NET Framework 4.x legacy applications
 
0
The story behind New descendant of .NET Framework, .NET Core, comes with one really useful pattern for reading and using configuration files. It comes with out of the box support for JSON configuration files which are much more readable and give much greater freedom and flexibility on how to organize your settings...read more
Strongly typed configuration sections with options pattern in ASP.NET Core
Loading configuration values directly to classes and use them in the runtime
0
Configuration is probably the most essential part of every application, yet we do not give much attention to it during application design and development. .NET Core has quite nice way to store configurations (usually JSON files) and already built-in extensions to access configuration values and directly cast them to a specific type...read more
Writing Azure WebJobs with dependency injection in .NET Core
Take advantage of .NET Core native dependency injection in Azure WebJob
 
0
WebJobs are a great way to run recurrent background tasks that support your application. They come as a part of Azure App Service/Web App serverless model...read more
Using dispatcher class to resolve CQRS commands and queries in ASP.NET Core
Injecting dispatcher class instead of multiple commands and queries in controller constructor
0
Recently I wrote an article about Automatic CQRS handler registration in ASP.NET Core with reflection in order to reduce number of lines for registering command and query to IOC container in ASP.NET Core. However, this solution does reduce lines for service registration in the startup, you still need to add all command and query handlers as parameters to the controller constructor. ...read more
Managing images on filesystem using Repository pattern in .NET Core
Repository pattern in action for managing files
0
It is not uncommon that for records in database you need to store image files or other documents related to the specific record on the file system. Storing documents related to the database records on the file system is not a silver bullet...read more
Registering multiple implementations of the same interface in ASP.NET Core
Multiple implementations of an interface in .NET Core Dependency Injection
0
Starting from it's initial release ASP .NET Core comes with built in dependency injection (DI) to help implement Inversion Of Control design pattern. This is not something new in .NET and apart from built-in DI in .NET Core, there are other libraries which provide same and in some cases even more advanced dependency injection implementation...read more
Dependency injection with custom MVC filter attributes in ASP.NET Core
Using dependency injection with custom ExceptionFilterAttribute in ASP.NET Core
0
Apart from adding your own middleware to the ASP.NET MVC Core application pipeline, you can control the response using custom MVC filter attributes and selectively apply them to either whole controller or controller actions. One of the commonly used MVC filter in ASP.NET Core is ExceptionFilterAttribute for handling error response in Wep API applications. It is easy to implement and I also wrote an article about Error handling in ASP.NET Core Web API few months ago...read more
Sending email in ASP.NET Core using SmtpClient and dependency injection
Using dependency injection to send email in ASP.NET Core
0
Starting with .NET Core 2.0, Microsoft introduced SmtpClient, identical implementation as in .NET 4. This made sending emails from the application a lot easier as there is functionality out of the box and you do not have to rely on the 3rd party nuget packages. If you inspect this class, you will see that the only interface it inherits is IDisposable, so it does not give you many options for injection unless you wrap it with your own implementation and interface, but since we are not going to go that deep into the dependency injection, we'll just focus on creating a client instance using .NET Core dependency injection framework. ...read more
Using strongly typed objects with IDistributedCache instead of byte arrays
An easy way to cache any object to distributed cache store using .NET Core
0
Saving an object to distributed cache store in .NET Core requires your object to be serialized to byte array in order for SetAsync method on Microsoft.Extensions.Caching.Distributed.IDistributedCache interface implemented instance to save your object to the injected cache store instance. This means that what ever instance you have, you need to serialize it first to byte array. Similar, just reversed process applies for the process of reading an object from the distributed cache store. ...read more

.NET

read more

JavaScript

read more

SQL/T-SQL

read more

Umbraco CMS

read more