unit-of-work

Multiple UnitOfWorks, ISession and repositories

假如想象 提交于 2019-12-25 02:03:36
问题 Do you know a good example somewhere for this? What I would like is the following: using(IUnitOfWork uow = UnitOfWork.Start()) { repositoryA.Add(insanceOfA); repositoryB.Add(instanceOfB); uow.Commit(); } But this case is too ideal, because what I also want is multiple UnitOfWorks (per presenter in most cases, and this is not for a web app). In that case, how will repositories know which UnitOfWork to use if I don't give them that explicitly like repository.UnitOfWork = uow; My goal is to have

Ninject Scope and System.Threading.Timer

别来无恙 提交于 2019-12-24 18:41:05
问题 How to invoke a new Ninject context on a Timer task? Having a hard time configuring ninject scope to unitofwork. If I set as InRequestScope() it doesn't work on non request tasks. So I set up like below so that I can get InThreadScope for tasks: kernel.Bind<IUnitOfWork>().To<myEntities>().InScope(ctx => HttpContext.Current ?? StandardScopeCallbacks.Thread(ctx)); But that way, when I set up a timer Timer timer = new Timer(_ => DelayedDisconnect(chatUser.User.AuthorizationId), null, TimeSpan

Autofac PerLifetimeScope vs PerRequest in web applications

杀马特。学长 韩版系。学妹 提交于 2019-12-24 15:22:48
问题 Using Autofac DI container- What is the difference between registering a unit of work in my web application as per request to registering it as PerLifetimeScope? Autofac creates a new scope for each request and by registering the unit of work as PerMatchingScope it will anyways be resolved from the scope created for the request. If I'm mistaken, please correct me, otherwise, what is the difference? Moreover, If I register the UoW as PerLifetimeScope, and have a console application that sends

UnitOfWork per screen in a client app using Windsor Castle

若如初见. 提交于 2019-12-24 10:13:51
问题 I'm use to build my app using MVVM + DDD. So usually my layers relation are View(ViewModel presenter) ViewModel(Service service) Service(IUnitOfWork uow, IRepository1 rep1, IRepository2 rep2) Repository1(IUnitOfWork uow, EnitityFatory1 ef1) Repository2(IUnitOfWork uow, EnitityFatory2 ef2) I'm use to resolve dependency with Windsor, so all classes as per metacode above have been installed into the container usually w/ Lifestyle.Transient for all of them but UnitOfWork. In case of a web app,

Mocking Context and Repository with UnitOfWork

半城伤御伤魂 提交于 2019-12-24 09:29:46
问题 I am building out unit tests for a small app we need to build. I have implemented the Repository / Unit Of Work pattern. My manager classes implement the unit of work pattern. For a given interface: public interface IUserManager { List<ApplicationUser> GetUsers(Expression<Func<ApplicationUser, bool>> filter = null); ApplicationUser GetUser(Expression<Func<ApplicationUser, bool>> filter); ApplicationUser AddUser(string username, List<string> environmentIds, bool isAdmin = false); void

Entity Framework returning old data

天大地大妈咪最大 提交于 2019-12-23 07:16:14
问题 I have a problem with EF not returning the newest data in a 3 layered WPF application, and I suspect it has something to do with how I handle the lifetime of my context. This is the scenario: There are several repositories wrapped inside a UnitOfWork. There is also one service (MyService), which uses the UnitOfWork. This UnitOfWork must also be called from the UI directly, without passing through a service. In the ViewModel of my main window at some point I create a new window (using

Entity Framework returning old data

∥☆過路亽.° 提交于 2019-12-23 07:15:52
问题 I have a problem with EF not returning the newest data in a 3 layered WPF application, and I suspect it has something to do with how I handle the lifetime of my context. This is the scenario: There are several repositories wrapped inside a UnitOfWork. There is also one service (MyService), which uses the UnitOfWork. This UnitOfWork must also be called from the UI directly, without passing through a service. In the ViewModel of my main window at some point I create a new window (using

Repository vs. UnitOfWork [closed]

对着背影说爱祢 提交于 2019-12-23 05:48:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 years ago . My current point of view is that repository should contain entity-specific modification methods like Add, Delete, etc. and UnitOfWork should contain just methods that are relevant to it in general like Commit (also known as SaveChanges, SubmitChanges) and Rollback (also known as ClearChanges). But Martin Fowler

How do I use DTO's with EF, Autofac, and a generic data repository?

回眸只為那壹抹淺笑 提交于 2019-12-23 05:22:09
问题 How do I use DTO's with EF, Autofac, and a generic data repository? I'm in the process of setting up a new project and have configured my DI/IoC (Autofac), using a generic repository for data access through EF, and created an OData service endpoint, ContentTypesController . Here's the top part of the controller: public class ContentTypesController : ODataController, IContentTypesController { // add repository reference private readonly IRepository<ContentType> _repository; private

How to add multi DbContext With UnitOfWork & DatabaseFactory & Generic Repository

可紊 提交于 2019-12-23 04:57:10
问题 I want to add TWO DbContext in My ASP.NET MVC 5 App, One DbContext For ASPIdentity and The Other For My APP DB. I am Using Repository Pattern. m y problem is, How to To specify the Entity of each DbContext in BaseRepository ? Here Is What I did. 1- DatabaseFactory & IDatabaseFactory public class DatabaseFactory<T> where T : DbContext,new() { private T dbContext; public T Init() { return dbContext ?? (dbContext = new T()); } } public interface IDatabaseFactory<T> where T : DbContext { T Init()