unit-of-work

Single threading a task without queuing further requests

与世无争的帅哥 提交于 2019-12-03 06:35:02
I have a requirement for a task to be executed asynchronously while discarding any further requests until the task is finished. Synchronizing the method just queues up the tasks and doesn't skip. I initially thought to use a SingleThreadExecutor but that queues up tasks as well. I then looked at the ThreadPoolExecutor but it reads the queue to get the task to be executed and therefore will have one task executing and a minimum of one task queued (the others can be discarded using ThreadPoolExecutor.DiscardPolicy). The only thing I can think off is to use a Semaphore to block the queue. I've

The unit of work pattern within a asp.net mvc application

谁说胖子不能爱 提交于 2019-12-03 06:23:33
问题 I have been looking at this excellant blog titled "NHibernate and the Unit of Work Pattern" and have a question regarding the best place to use UnitOfWork.Start in a asp.net mvc project. My SLN is broken down into the following projects:- MVC project Repository NHibernateUnitOfWork I have an interface:- public interface INameRepository ... IList<Name> GetByOrigin(int OriginId) ... I have a concrete implementation public class NameRepository : INameRepository ... public IList<Name> GetByOrigin

Undefined index error upon $em->clear() in Symfony2

自古美人都是妖i 提交于 2019-12-03 05:50:50
I have written a Symfony command to import some data from an API. It works but the problem is my PHP memory usage increases when I insert a big JSON in my database. And my unitOfWork increases by '2' to after each activty import. I have already unset all my used objects, and I have read the documentation of Symfony2 when you want to do massive batch: http://www.doctrine-project.org/blog/doctrine2-batch-processing.html But when I use $em->clear() my entity manager gives this error: Notice: Undefined index: 000000007b56ea7100000000e366c259 in path-to-application\vendor\doctrine\lib\Doctrine\ORM

Using multiple DbContexts with a generic repository and unit of work

坚强是说给别人听的谎言 提交于 2019-12-03 05:23:44
问题 My application is getting larger and so far I have a single MyDbContext which has all the tables I need in my application. I wish (for the sake of overview) to split them up into multiple DbContext , like MainDbContext , EstateModuleDbContext , AnotherModuleDbContext and UserDbContext . I am unsure how this is done probably as I am right now using dependecy injection (ninject) to place my DbContext on my UnitOfWork class like: kernel.Bind(typeof(IUnitOfWork)).To(typeof(UnitOfWork<MyDbContext>

Practical usage of the Unit Of Work & Repository patterns

邮差的信 提交于 2019-12-03 05:04:22
问题 I'm building an ORM, and try to find out what are the exact responsibilities of each pattern. Let's say I want to transfer money between two accounts, using the Unit Of Work to manage the updates in a single database transaction. Is the following approach correct? Get them from the Repository Attach them to my Unit Of Work Do the business transaction & commit? Example: from = acccountRepository.find(fromAccountId); to = accountRepository.find(toAccountId); unitOfWork.attach(from); unitOfWork

Calling commands from within another command Handle() method

会有一股神秘感。 提交于 2019-12-03 03:21:03
Hi I am using the Simple Injector DI library and have been following some really interesting material about an architectural model designed around the command pattern: Meanwhile... on the command side of my architecture Meanwhile... on the query side of my architecture The container will manage the lifetime of the UnitOfWork , and I am using commands to perform specific functions to the database. My question is if I have a command, for example an AddNewCustomerCommand , which in turn performs another call to another service (i.e. sends a text message), from a design standpoint is this

Repository and Unit of Work patterns - How to save changes

余生长醉 提交于 2019-12-03 02:55:09
问题 I'm struggling to understand the relationship between the Repository and Unit of Work patterns despite this kind of question being asked so many times. Essentially I still don't understand which part would save/commit data changes - the repository or the unit of work? Since every example I've seen relates to using these in conjunction with a database/OR mapper let's make a more interesting example - lets persist the data to the file system in data files; according to the patterns I should be

Correct disposing using Repository and Unit Work patterns with Entity Framework?

社会主义新天地 提交于 2019-12-03 02:51:22
Cheers!I have some doubts about using Unit of Work with Repository. Specially a role of child context from Entity Framework. I have searched a lot of information about this theme, but all that I found just different types of using patterns, I'm confused and I can't understand main think. 1.Where I should realize disposing and saving? -Is it correctly realize Disposable in Inheritance class of DbContext? After that realize in Repository and Unit of Work or just in Uni fo Work? -Where put method Save in Unit of Work or Repository? My repository will be Generic Is my code is correct in architect

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

老子叫甜甜 提交于 2019-12-03 01:36:57
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: this.container.RegisterType<IConnectionStringFactory, ConnectionStringFactory>(new

Where should I create the Unit of Work instance in an ASP.Net MVC 3 application?

泄露秘密 提交于 2019-12-02 23:32:23
I have read as many of the posts on Stackoverflow as I can find with regards the use of a Unit of Work pattern within an ASP.Net MVC 3 application which includes a Business Layer. However, I still have a couple of questions with regards this topic and would greatly appreciate any feedback people can give me. I am developing an ASP.Net MVC 3 Web application which uses EF 4.1. I will be using both the Repository and Unit of Work Patterns with this project similar to how they are used in this great tutorial The difference in my project is that I need to also include a Business Layer (separate