Questions tagged [autofac]

Autofac is an Inversion of Control container for .NET 4.5, Silverlight 5, Windows Store apps, and Windows Phone 8 apps. See autofac.org for more information.

Filter by
Sorted by
Tagged with
1 vote
2 answers
549 views

Should I get Autofac to include classes that don't have a public constructor?

I have a Asp.Net API (.NET Framework 4.7.2). We recently updated Autofac to version 6.2.0. Autofac does not like some of our classes that don't have a public constructor. Example class: ...
Randy's user avatar
  • 487
2 votes
0 answers
541 views

How to make a good session handling with NHibernate?

here I leave my code for a repository pattern with NHibernate and Autofac. I would like to receive some feedback about it. Especially about the session handling with NHibernate. By now I don't like ...
biel sala's user avatar
1 vote
2 answers
644 views

Autofac support for connection strings

I would like Autofac to instantiate components based on connection strings in the form of the URI: ...
Dmitry Nogin's user avatar
  • 6,133
4 votes
2 answers
295 views

Registering Named services and resolving them by T

Problem statement I have an application that needs to get files from various sources (disk, embedded, http, ftp, ...) so I use a common API for them: ...
t3chb0t's user avatar
  • 44.1k
2 votes
2 answers
9k views

Using Autofac to do DI in a static factory method

I'm using Autofac to create one of my classes inside of a static factory method Create. This code is working and I haven't noticed any side effects yet. Admittedly, ...
t3chb0t's user avatar
  • 44.1k
2 votes
1 answer
990 views

Using constructor dependency injection in a custom mapper class

I am quite new to DI and its patterns so I decided to place my code for some review. I am working on an digital map application using .NET Core 2.0. I am using the standard DI framework of ASP.NET ...
mirind4's user avatar
  • 299
3 votes
1 answer
2k views

Unit testing a prism event

I am currently working on a C# WPF project following the MVVM design pattern. I am using Autofac and Prism as core frameworks in the design. For unit testing I am using Xunit and Moq. I am also using ...
Cameron Hurst's user avatar
1 vote
1 answer
1k views

UnitOfWork without repository and transaction

I've created the unitofwork class below: ...
Rod's user avatar
  • 131
8 votes
1 answer
6k views

Service-Repository pattern with IoC, NPoco micro-ORM and unit tests

I'm trying to build a Web API using best practices, based on a simple proof-of-concept using students. My goal is to build the system using: Onion Architecture to seperate concerns. Service-...
Gaui's user avatar
  • 621
2 votes
1 answer
6k views

DAL basic implementation using Entity framework 6 and Autofac

Would like to ask for a code review for my DAL. I use Entity framework 6 and Autofac for ...
user avatar
1 vote
2 answers
258 views

Entity framework - code first data access

I'm looking for your opinions about ways to improve the access to data in my application. I develop web applications, using Entity Framework 6 code first, and Autofac for dependency injection. Before ...
user avatar
3 votes
1 answer
420 views

Configuring MVC 5 project with service layer and DI and UOW

In the past I have always called the repositories directly from the controller, but that is a bad practice and now I am implementing a "Business Layer" to my project. Would I have two UnitOfWorks? ...
Andrew's user avatar
  • 133
10 votes
2 answers
4k views

Allowing query handlers to use other query handlers

I recently started looking into CQRS when using Entity Framework and the impact it has had on my systems has been overwhelming. I implemented the following patterns described in these blog posts: ...
Mathias Lykkegaard Lorenzen's user avatar
20 votes
1 answer
34k views

Autofac DI container in console app

Just used DI containers in MVC projects, via constructor injection, and I'd need to now inject a service into a console app. I'm using Autofac so I followed what I found here. The code would be ...
mitomed's user avatar
  • 539
4 votes
1 answer
4k views

Generic Repository, UnitOfWork and IOC container

I am stuck to define a generic repository with AutoFac IOC container. I am keeping thing very simple and only showing relevant information. BaseEntity ...
Imran Qadir Baksh - Baloch's user avatar
10 votes
1 answer
815 views

Should a Factory ever be generated per request?

I'm working with AutoFac to do some DI. I think I've got a decent grip on things, but just ran into a question I had with my code and thought I'd check: ...
Sean Anderson's user avatar