It's the beauty of relationship types, that they can work in conjunction with one another. Therefore, we can compose relationship types to solve a particular problem.
The article talks about scenarios where we want more than one instance of a given service
Generally speaking, an owned dependency corresponds to some unit of work performed by the dependent component.
In this video, I have talked about optimizing an application by using Lazy Initialization in an application that is using dependency injection and is therefore loosely coupled.Enjoy the video.
Lazy<T,TMetadata> is a type provided by MEF to hold indirect references to exports. Here, in addition to the exported object itself, you also get export metadata, or information that describes the exported object.
When we inject a dependency as Lazy<T>, we delay the construction of part of the object graph either for functional or performance reasons. Moreover, Lazy<T> will be automatically injected, as long as T is registered with the DI container.
In this post, we will be talking about the two most commonly used types of relationships, namely, direct dependency relationship and enumeration.
This video aims to demonstrate, how we can write unit test for a loosely coupled application using NUnit and NSubstitute.
The "Service Locator" pattern, while widely used, often leads to issues in software design, making it an anti-pattern in the context of Dependency Injection (DI). This article explores the drawbacks of Service Locator, including increased coupling, reduced testability, and maintenance challenges.
In this video, I have talked about dependency injection using Autofac.
Service locator pattern is one of the most commonly used patterns. In general, this pattern is used along with other patterns like Adapter Pattern, Observer Pattern, Dependency Injection Principles and many more. In this post, however, we will be talking about its use with dependency injection, which is one its many uses.
While I was exploring Autofac, I found AsImplementedInterfaces quite interesting. Not only because it is useful, but also because if we are not careful with its use, we may end up with unexpected application behavior.
A DI container takes the responsibility of instantiating and providing the dependency instances, irrespective of the level of dependencies. As a result, it is a container that manages the scope of the instantiated objects.
Dependency Injection (DI) is a technique that helps us achieve loose coupling between objects and their collaborators. In this post, we will use constructor based dependency injection, however, we are not going to use any DI container for now.
In this video, we looked at a tightly coupled application and tried to understand the problems associated with the same. You may also visit my article about the same at http://www.c-sharpcorner.com/article/dependency-injection-day-1/
If a component or class depends upon other components to complete its operations, then these other components are dependencies for this class. Our class can have these dependencies as implicit or explicit dependencies.
A loosely coupled application has good isolation among its classes, modules and assemblies. Therefore, if we make a change to one part of the application, we only need to update the relevant modules. We do not need to make changes throughout the application.
It is a best practice to use interfaces instead of concrete classes. These interfaces can then be mocked at the time of unit testing, which will prevent any call to the actual database. Also, it is a good practice to stop "newing-up" objects in classes.

Pre/Post build events are useful when we wish to perform some operation before/after a project is built. These operations are nothing but the Shell commands being used from the command line. A build event can be formed using a single, multiple, or conditional commands.
Learn how the Null Object pattern replaces null references with do-nothing objects to avoid repeated null checks and NullReferenceException errors in C#.
Object relationships define how different classes interact in an application. Collaboration (uses-a), Aggregation (has-a), and Inheritance (is-a) are key types. For instance, Customer and Order use aggregation, while Order and OrderItem show composition.

Generally, for an object to have some properties, the type of the object has to be defined first. On the contrary, anonymous types provide a convenient way for an object to encapsulate readonly properties without explicitly defining the type first. The type of each property is deduced by the compiler.

Different people define Entity, Model, ViewModel and DataModel in different ways. However, these terms may sometimes differ from their actual meaning, based upon the context. However, through this article, I would like to share my understanding of these terms.
It has been quite a long time since "var" was introduced, yet it is still a topic of debate among .net developers.

An assembly is a block of compiled code which is reusable, versionable, and self-describing. It is an assembly that takes the form of an executable (.exe) file or dynamic link library (.dll). When we build our application, all the .cs files are put together to form an assembly.
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegisterMembers onlyWrite an article and earn +1,000 SHARP when it is approved.
Write an article