unit-of-work

“Argument not specified for parameter” using Ninject in web forms

ε祈祈猫儿з 提交于 2019-12-11 15:05:26
问题 Just to re-iterate the title, this is web forms and not mvc. Also it's using vb.net. I have used nuget to add ninject.web to my project. I have configured NinjectWebCommon's "RegisterServices" method as follows: Private Shared Sub RegisterServices(kernel As IKernel) kernel.Bind(Of ilbdUOW)().[To](Of lbdUOW)() End Sub Everything compiles clean. When I run the simple web form (.aspx page, no master page), I get the following error: BC30455: Argument not specified for parameter '_uow' of 'Public

Multiple dbcontexts with Repository, UnitOfWork and Ninject

那年仲夏 提交于 2019-12-11 07:45:16
问题 I am slowly getting to grips with EF, repository, UnitOfWork and Ninject and have included my implementation so far (see below). The purpose of my data layer is to provide the ability to read data from the existing HR system which has an Oracle back end, and provide addition functionality by consuming this data. The application I am building will use a SQL backend, currently I have just created some extra tables in the HR systems Oracle dbm but I want to keep this separate and hook in to

UnitOfWork, Repository Database Connection Issue

拥有回忆 提交于 2019-12-11 05:35:18
问题 I'm using Unity for Dependency Injection. I implemented generic repository IRepository<T> and IUnitOfWork as per direction mentioned here Now when I access Repository and UnitOfWork in Service layer using constructor injection, it adds the data in database but never closes connection with database. UnitOfWork implements IDisposable but that's never called since I'm not able to implement Using pattern knowing the fact that Repository and UnitOfWork is being shared by other functions also.

How does unit of work class know which repository to call on commit?

為{幸葍}努か 提交于 2019-12-11 05:15:49
问题 * Preface: I'm pretty new to the unit of work pattern * My goal is to implement a unit of work class that will be able to keep track of all objects that have been changed throughout a given transaction. Everything I read about the unit of work pattern has it side by side with the repository pattern. So this is the approach I'd like to use. Say for example I create a new User. On my unit of work object, I have a list of newly created objects, so I add my new User to this list. My user

Register generic types in SimpleInjector Version 3

a 夏天 提交于 2019-12-11 04:43:14
问题 I've been following the very helpful answer here to organise my unit of work and repositories dynamically using SimpleInjector DI. Using the test service below: public class TestService { public TestService(IRepository<Call> calls){} } In the controller: public class TestingController : Controller { private readonly IUnitOfWork _unitOfWork ; public TestingController(IUnitOfWork unitOfWork, TestService testService) { _unitOfWork = unitOfWork; } } And the bootstrapper: public static class

EF 4.1 DBContext AutoDetectChangesEnabled

天大地大妈咪最大 提交于 2019-12-11 01:17:00
问题 OK. I have turned off AutoDetectChangesEnabled, and when I query the context, modify an entity and attempt to save changes, nothing gets updated. I would expect that. But when I mark the entity as modified, I would expect it to change. Any ideas? I am using the UnitOfWork, Repository, Service pattern. If I enable AutoDetectChangesEnabled then all is fine. What is the standard way to persist changes to attached objects? What about detached objects? Thanks in advance, Sam 回答1: It's not just

Implementing Generic Repository using Entity framework code first

若如初见. 提交于 2019-12-10 19:33:48
问题 I'm experiencing my first try on implementing Generic Repository Pattern and Unit of framework. I'm not using MVC on the project in hand. Please take a look at this method included in Generic Repository class: public virtual IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = "") { IQueryable<TEntity> query = dbSet; if (filter != null) { query = query.Where(filter); } foreach

Using Entity Framework with repository pattern in WinForms MDI

独自空忆成欢 提交于 2019-12-10 14:22:30
问题 We are about to start up a new project similar to a previous one. I could just copy the old design but I am not all too satisified with the old design. It is a "standard" business system (sales,stocktaking,warehousing etc) built ontop of .Net 3.5 (Winforms MDI) with Entity Framework in the backend. All forms inherit from a baseform (which inherits Windows.Form). The form exposes a property called ObjectContext, which on the first call instantiates a new ObjectContext. This makes up a pretty

UnitOfWork Implementation

故事扮演 提交于 2019-12-09 13:13:53
问题 Ive been able to implement a little cool unit of work to work with entity framework. I came up with .. public class UnitOfWork : IUnitOfWork { private Database _database; private IDatabaseFactory _databaseFactory; private DbTransaction transaction; public UnitOfWork(IDatabaseFactory databaseFactory) { _databaseFactory = databaseFactory; _database = Database; transaction = _database.Database.Connection.BeginTransaction(); } public Database Database { get { return _database ?? (_database =

Entity Framework with multiple edmx

烂漫一生 提交于 2019-12-09 05:35:06
问题 Let's say I have in my database multiple db schema for example : HumanRessources and Inventory. In each of those schema contains multiple tables. Do you usually split your DB into multiple edmx or usually just put everything in one single edmx? I was thinking about creating a edmx for each schema, but wondering how this will impact a unitorwork pattern. Reading through some articles, the ObjectContext will be the unitofwork. By defining 2 edmx, I will end up with 2 ObjectContext :