unit-of-work

Reusable Querying in Entity Framework WITHOUT Repository. How?

亡梦爱人 提交于 2019-12-05 05:13:10
Let me say, I have come to the conclusion (after a lot of trial) that Repository & Unit of Work when using Entity Framework is just wrong, wrong, wrong and this says why quite well. But I really hate on those embedded queries. Question is, where can I put them instead if I'm so against a repository, etc? (clean answers only please, examples much appreciated). I just nuked two projects containing my repositories, unit of work and interfaces with hundreds of files because the payback was nowhere to be seen. I think lots of people, myself included, just jumped on the Repository bandwagon because

Preparing for multiple EF contexts on a unit of work - TransactionScope

╄→尐↘猪︶ㄣ 提交于 2019-12-05 02:24:39
问题 I'm thinking of the options in regards to implementing a single unit of work for dealing with multiple datasources - Entity framework. I came up with a tentative approach - for now dealing with a single context - but it apparently isn't a good idea. If we were to analyze the code below, would you consider it a bad implementation? Is the lifetime of the transaction scope a potential problem? Of course if we wrap the transaction scope with different contexts we'd be covered if the second

UnitOfWork in Action Filter seems to be caching

僤鯓⒐⒋嵵緔 提交于 2019-12-05 01:37:26
I have an MVC 3 site that uses IoC (Unity), and my model is generated w/ EF4 and POCOs. I am using an action filter to commit my UnitOfWork: public class UseUnitOfWorkAttribute : ActionFilterAttribute, IActionFilter { private readonly IUnitOfWork _unitOfWork; public UseUnitOfWorkAttribute() { _unitOfWork = IoCFactory.Instance.CurrentContainer.Resolve<IUnitOfWork>(); } void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext) { _unitOfWork.Commit(); } void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) { } } However, even though the Commit() seems to be

Unit of work when using MassTransit

浪子不回头ぞ 提交于 2019-12-05 01:29:40
问题 I'm looking for a way to hook on the message handling pipeline and do some work after a consumer finishes handling some message. My intention is to open a new session and start a transaction(could be done the IoC Container) before handling and disposing them right after it. In NServiceBus I would use the IMessageModule interface to hook in. does have anything similar to it? Actually disposing the the handler would also do it for, but as I'm using StructureMap as the ObjectBuilder, the Release

ASP.NET MVC WebApi: No parameterless constructor defined for this object

时光总嘲笑我的痴心妄想 提交于 2019-12-04 20:15:36
问题 I have an ASP.NET MVC 4 Application that I want to implement Unit of Work Pattern. In my Web Project I have: IocConfig.cs using System.Web.Http; using NinjectMVC.Data; using NinjectMVC.Data.Contracts; using Ninject; namespace NinjectMVC { public class IocConfig { public static void RegisterIoc(HttpConfiguration config) { var kernel = new StandardKernel(); // Ninject IoC // These registrations are "per instance request". // See http://blog.bobcravens.com/2010/03/ninject-life-cycle-management

best practice to implement repository pattern and unitOfWork in ASP.NET MVC [closed]

落爺英雄遲暮 提交于 2019-12-04 19:39:08
Closed . This question is opinion-based . It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed 5 years ago . I am working on implementing Repository Pattern and UnitOfWork from last few days, which I have completed to upto good extend, I believe. I am sure there are plenty of ways to implement that but what I am interesting to find best approach for that. I am taking very simple example coded in ASP.NET MVC 5 using visual studio 2013. my main focus of question is implementation of

Design for multi-tenant app using SOA, UoW, Repository, DataContext & multiple databases

六月ゝ 毕业季﹏ 提交于 2019-12-04 19:02:38
Let me start by apologizing for the length of this post but I wanted to provide as much detail as possible to increase the chance of an answer. Thanks in advance. I’m adding new features to an existing application that integrates data from several databases. In short, it allows clients and/or their accountants to access and update financial information about their locations. The application has 3 tiers with a web client (I’m looking to replace this will a Silverlight client very soon), a service layer running on an app server and the database tier. When I took ownership, the application,

Creating Entity Framework objects with Unity for Unit of Work/Repository pattern

两盒软妹~` 提交于 2019-12-04 18:16:26
I'm trying to implement the Unit of Work/Repository pattern, as described here: http://blogs.msdn.com/adonet/archive/2009/06/16/using-repository-and-unit-of-work-patterns-with-entity-framework-4-0.aspx This requires each Repository to accept an IUnitOfWork implementation, eg an EF datacontext extended with a partial class to add an IUnitOfWork interface. I'm actually using .net 3.5, not 4.0. My basic Data Access constructor looks like this: public DataAccessLayer(IUnitOfWork unitOfWork, IRealtimeRepository realTimeRepository) { this.unitOfWork = unitOfWork; this.realTimeRepository =

How to peek at message while dependencies are being built?

末鹿安然 提交于 2019-12-04 16:17:12
I building multitenancy into the unit of work for a set of services. I want to keep the tenancy question out of the way of day-to-day business domain work, and I do not want to touch every existing consumer in the system (I am retrofitting the multitenancy onto a system without any prior concept of a tenant). Most messages in the system will be contexted by a tenant. However, there will be some infrastructure messages which will not be, particularly for the purpose of automating tenant creation. I need a way of determining whether to use a tenant-contexted unit of work, or a infrastructure

Service Layer/Repository Pattern

南楼画角 提交于 2019-12-04 13:58:14
问题 I am building an MVC app using the Service Layer/Repository/Unit of Work pattern with EF4. I am a bit confused on the logic. I know the point is to decouple the system, but I am a little confused. So the MVC Controllers call on the Services to fill the View Models. So is it safe to say the MVC App is coupled to the Service Layer? Then the Service Layer calls on the Repository to get and persist objects. Is then safe to say the Service Layer is dependent to the Repository? The Repository the