repository-pattern

Looking for a Ninject scope that behaves like InRequestScope

二次信任 提交于 2019-11-26 08:37:19
问题 On my service layer I have injected an UnitOfWork and 2 repositories in the constructor. The Unit of Work and repository have an instance of a DbContext I want to share between the two of them. How can I do that with Ninject ? Which scope should be considered ? I am not in a web application so I can\'t use InRequestScope . I try to do something similar... and I am using DI however, I need my UoW to be Dispose d and created like this. using (IUnitOfWork uow = new UnitOfWorkFactory.Create()) {

How to implement Unit Of Work pattern with Dapper?

六眼飞鱼酱① 提交于 2019-11-26 07:45:42
Currently, I am trying to use Dapper ORM with Unit Of Work + Repository Pattern. I want to use Unit of Work as opposed to a simple dapper Repository due to the fact that my insert and updates require a degree of transaction processing. I have been unable to find any useful examples as most seem to use Entity Framework and have leakage issue within the Unit of Work. Could someone please point me in the right direction? This Git project is very helpful. I started from the same and did some changes as per my need. public sealed class DalSession : IDisposable { public DalSession() { _connection =

Is UnitOfWork and GenericRepository Pattern redundant In EF 4.1 code first?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 07:29:36
问题 Wondering if I need to use the Genericrepository pattern and UnitOfWork to mock the repository.I am using MOQ.Is it now redundant since I have noticed that EF 4.1 has IDBSet. I have not figured out how to write something generic that usic IDBSet .If you have an example where you implement IDBSet can you show it to me? Any suggestions? 回答1: This is duplicate of many topics already discussed on SO but I agree that some of them can be hard to find because they are nested in other question What's

When to use PerThreadLifetimeManager?

你说的曾经没有我的故事 提交于 2019-11-26 05:38:20
问题 I am following the example linked to below for setting up unity to work with my service layer. My project is setup very similar to the one in this article and I understand everything except why exactly is PerThreadLifetimeManager used when registering the service dependency. Keep in mind I am also using a generic repository and unitofwork that is being used in my service layer as well. Most unity examples use the default(transient) lifetime manager, and since my setup is similar to the one

NOT using repository pattern, use the ORM as is (EF)

大城市里の小女人 提交于 2019-11-26 04:58:54
问题 I always used Repository pattern but for my latest project I wanted to see if I could perfect the use of it and my implementation of “Unit Of Work”. The more I started digging I started asking myself the question: \"Do I really need it?\" Now this all starts with a couple of comments on Stackoverflow with a trace to Ayende Rahien\'s post on his blog, with 2 specific, repository-is-the-new-singleton ask-ayende-life-without-repositories-are-they-worth-living This could probably be talked about

Difference between Repository and Service Layer?

佐手、 提交于 2019-11-26 04:02:55
问题 In OOP Design Patterns, what is the difference between the Repository Pattern and a Service Layer? I am working on an ASP.NET MVC 3 app, and am trying to understand these design patterns, but my brain is just not getting it...yet!! 回答1: Repository Layer gives you additional level of abstraction over data access. Instead of writing var context = new DatabaseContext(); return CreateObjectQuery<Type>().Where(t => t.ID == param).First(); to get a single item from database, you use repository

What is the difference between DAO and Repository patterns?

こ雲淡風輕ζ 提交于 2019-11-26 04:02:46
问题 What is the difference between Data Access Objects (DAO) and Repository patterns? I am developing an application using Enterprise Java Beans (EJB3), Hibernate ORM as infrastructure, and Domain-Driven Design (DDD) and Test-Driven Development (TDD) as design techniques. 回答1: DAO is an abstraction of data persistence . Repository is an abstraction of a collection of objects . DAO would be considered closer to the database, often table-centric. Repository would be considered closer to the Domain,

Generic Repository or Specific Repository for each entity?

夙愿已清 提交于 2019-11-26 03:27:05
问题 Background At the company I work for I have been ordered to update an old MVC app and implement a repository pattern for a SQL database. I have created the context of the database using Entity Framework Database-First and got 23 entities. The first question Do I need to create a repository for each entity or implement a generic repository for the context? I\'m asking this because I have found following while searching internet: One repository per domain You should think of a repository as a

Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable

送分小仙女□ 提交于 2019-11-26 03:01:27
I'm playing with the latest Entity Framework CTP 5 release and building a simple asp.net MVC blog where I just have two tables: Post and Comments. This is done entirely in POCO, I just need help on the DbContext part, where I need it to be unit testable (using IDbSet?) and I need a simple/generic repository pattern for add, update, delete, retrieval. Any help is appreciated. Thanks. Paul Start with you DbContext, create a new file called Database.cs: Database.cs public class Database : DbContext { private IDbSet<Post> _posts; public IDbSet<Post> Posts { get { return _posts ?? (_posts = DbSet

EF Including Other Entities (Generic Repository pattern)

不打扰是莪最后的温柔 提交于 2019-11-26 02:27:04
问题 I am using the Generic Repository pattern on top of Entity Framework Code First. Everything was working fine until I needed to include more entities in a query. I got to include one entity successfully, but now I can\'t figure out how to include multiple entities. Check out what I\'ve got so far: public IQueryable<TEntity> GetQuery<TEntity>() where TEntity : class { var entityName = GetEntityName<TEntity>(); return _objectContext.CreateQuery<TEntity>(entityName); } public IList<TEntity>