unit-of-work

Why the database data is not being updated but object did and without error?

风格不统一 提交于 2020-01-23 06:51:28
问题 I have this bank ATM mock-up app which implements some Domain-Driven Design architecture and Unit of Work pattern. This app have 3 basic functions: Check balance Deposit Withdraw These are the project layers: ATM.Model (Domain model entity layer) namespace ATM.Model { public class BankAccount { public int Id { get; set; } public string AccountName { get; set; } public decimal Balance { get; set; } public decimal CheckBalance() { return Balance; } public void Deposit(int amount) { // Domain

Repository pattern with MongoDB - multiple units of work with one transaction

℡╲_俬逩灬. 提交于 2020-01-23 05:28:15
问题 I'm implementing a DAL abstraction layer on top of the C# Mongo DB driver using the Repository + Unit of Work pattern. My current design is that every unit of work instance opens (and closes) a new Mongo DB session. The problem is that Mongo DB only allows a 1:1 ratio between a session and a transaction, so multiple units of work under the same .NET transaction will not be possible. The current implementation is: public class MongoUnitOfWork { private IClientSessionHandle _sessionHandle;

Should I be using a Generic Repository with Entity Framework 5?

不打扰是莪最后的温柔 提交于 2020-01-22 13:37:12
问题 I'm currently using Entity Framework with a Generic Repository and Unit Of Work Pattern. My Model is similar to the one described in this article I've used Generic Repositories in the past and really enjoyed the global functionality it can provide. However, it seems I'm running into more problems every single day when it comes to using it with Entity Framework. These problems seem to arise even more when it comes to handling Parent/Children/Junction relationships. Using a Generic Repository

Should I be using a Generic Repository with Entity Framework 5?

孤街浪徒 提交于 2020-01-22 13:36:05
问题 I'm currently using Entity Framework with a Generic Repository and Unit Of Work Pattern. My Model is similar to the one described in this article I've used Generic Repositories in the past and really enjoyed the global functionality it can provide. However, it seems I'm running into more problems every single day when it comes to using it with Entity Framework. These problems seem to arise even more when it comes to handling Parent/Children/Junction relationships. Using a Generic Repository

SessionPerWebRequest UoW SimpleInjector ActionFilterAttribute

天涯浪子 提交于 2020-01-15 19:11:10
问题 I am using SimpleInjector and want to create a UnitOfWork Per WebRequest Using an UnitOfWorkFactory . I want to do this by using an ActionLiterAttribute so that every web request will begin a new UnitOfWork The only problem that I have is to pass the IUnitOfWorkFactory to the ActionFilterAttribute class. There is a similar question about this online but there is a solution given using Ninject , Unfortunately with SimpleInjection there is no equivalent to Bind a filter. This is what I have

Is unit of work a good pattern for transactions that will auto generate new objects (auto_increment id)?

拥有回忆 提交于 2020-01-14 00:33:50
问题 From the unit of work pattern i uderstand a method of doing typic transactions based on some domain repostiries (using a repository per domain object) . Example : after defining some repository objects in the UoW object , commit those repositories based on theyr state . Also the repositories should not contain any transaction logic . What happens when an insert() leads to a creation of a new object (auto generated id) that later on is needed by another object in the same transaction ? Unit of

Repository pattern with Linq to SQL using IoC, Dependency Injection, Unit of Work

送分小仙女□ 提交于 2020-01-12 02:04:31
问题 There seems to be lots of examples on implementing Repository pattern for Linq to SQL. Most of them featuring IRepository and DI; Some have implemented Unit of Work and some not. I tried to read as most of the results returned by searches on SO and Google on Linq to SQL repository patterns. Nevertheless I've not come across a complete solution yet. From my readings I've implemented a repository pattern as shown below: I'm using DI to register interfaces on which the repositories are depended:

How to force fire OnModelCreating every DataContext initialized up

好久不见. 提交于 2020-01-11 07:01:08
问题 I want to fire OnModelCreating every new DataContext(new Entity()) ... But when i create a connection of a table , it works. When create a connection for another table, OnModelCreating doesnt work again, so because i got error, the entity type <tableName> is not part of the model for the current context. public class DataContext : DbContext { private BaseEntity _entity; public DataContext(BaseEntity entity) { Database.Connection.ConnectionString = Parameters.ConnectionString; _entity = entity

How many repositories is too many?

℡╲_俬逩灬. 提交于 2020-01-06 08:43:17
问题 We are getting ready to modularize a large enterprise application that is currently using a dying stack of technologies. My question is in the Repository/Unit of Work pattern, how many Repositories can you have in a unit of work? Say for example we create a UnitOfWork on a single DbContext that exposes 50+ repository entities. Will this cause performance problems? We were looking at maybe splitting it up so that each schema has it's own DbContext but this seems to add a lot of complexity and

ninject inject iunitofwork to repository scoped attribute

风流意气都作罢 提交于 2020-01-04 11:08:14
问题 Let me start with my current setup, and then explain what I am trying to achieve. We are using NHibernate and trying to implement the IRepository/IUnitOfWork pattern with Ninject. It should ideally work generically for whatever application is using the code, whether is ASP.Net, WCF or something else. IUnitOfWork public interface IUnitOfWork { object Add(object obj);//all other supported CRUD operations we want to expose void Commit(); void Rollback(); } UnitOfWork public class UnitOfWork :