repository-pattern

UnitOfWork and Entity Framework Contexts

邮差的信 提交于 2019-12-08 07:49:03
问题 So the problem I am trying to solve is this; We are using Entity Framework to access our Oracle database that has 1200-1500 tables. Now mind you we are not accessing them all, but possibly could have 800+ to access. We are using the UnitOfWork --> Repository --> Service pattern and that works great, but we are trying to figure out if we should have one big DbContext, or multiple little contexts that are specific to the task at hand. Our UnitOfWork is setup using an EFUnitOfWorkBase like so:

Ninject Singleton for MVC Data Repository

Deadly 提交于 2019-12-08 06:24:26
问题 In my MVC3 app I have an IDataRepository interface which is referenced by all my controllers to give them access to the data layer. There's also a DataRepository class which is implements IDataRepository for a particular data source (an nHydrate-derived Entity Framework, in my case). The DataRepository class takes a single argument, which is the connection string to the underlying database. I've been successfully using nInject to to IoC with the controller classes using the following binding:

Help with Ninject in mvc3!

北城余情 提交于 2019-12-08 05:45:17
问题 Heres my problem. My app has several projects. WEB (Controllers and views) Services Data (edmx and Repositories) Entities (POCO) Tests So in my Web project I have the ninject configuration [assembly: WebActivator.PreApplicationStartMethod(typeof(PublicPanama.AppStart_NinjectMVC3), "Start")] namespace Web{ public static class AppStart_NinjectMVC3 { public static void RegisterServices(IKernel kernel) { //kernel.Bind<IThingRepository>().To<SqlThingRepository>(); kernel.Bind<IContributorService>(

How to use joins with generic repository pattern - Entity Framework

為{幸葍}努か 提交于 2019-12-08 05:42:23
问题 I have a Generic Repository like below which handles my CRUD , for a single entity its easy to use, problem starts when i try to join my POCOs . Lets say I have these POCO, they are mapped using fluent api (many to many and One to many relation) : public class Student { public Student() { this.Courses = new HashSet<Course>(); } public int StudentId { get; set; } public string StudentName { get; set; } //FKs public virtual Standard Standard { get; set; } public int StdandardRefId { get; set; }

Is it wise to use same DbContext with multiple repositories?

一曲冷凌霜 提交于 2019-12-08 05:13:18
问题 Getting deeper with entity framework and repositories in order to enable better testing. Wondering if this is wise though? public interface IRepository { int SaveChanges(); void Dispose(); } using (MyContext context = new MyContext()) { TransactionRepository txns = new TransactionRepository(context); // TransactionRepository implement IRepository MappingRepository maps = new MappingRepository(context); // MappingRepositoryimplement IRepository SomeCommand command = new SomeCommand(txns, maps)

Switches for LazyLoading with Repository pattern

天涯浪子 提交于 2019-12-08 04:50:33
问题 By default LazyLoading is disabled in my DbContext. I use repository pattern and in some case I need to get only simple object and in other I need to get object with values of navigations properties. How can I implement something like switches for LazyLoading? Any help will be appreciated I have one solution that works but I'm not sure that it is correct: in interface of repository I added new property public interface IRepository<T> where T : BaseEntity { T GetById(object id); void Insert(T

Managing connections with Generic Repository pattern

耗尽温柔 提交于 2019-12-08 04:37:58
问题 I am building a site using entity framework 4.1 and mvc3. I am using the Generic Repository pattern: http://www.tugberkugurlu.com/archive/generic-repository-pattern-entity-framework-asp-net-mvc-and-unit-testing-triangle. I use ninject to inject my concretes repositories to the controllers. My problem is that each of my dbcontext different and I cannot run complex queries without the code shouting something like "different contexts cannot be used in the same query". I tried using the

Can I access a repository from presentation layer?

十年热恋 提交于 2019-12-07 23:29:21
问题 I am starting with DDD. I am a bit confused with the interaction between the several layers involved in a DDD application. Can I call my repositories from my presentation layer? If not do I have to replicate the CRUD functionality provided by the repositories in my service layer (which ofcourse will in turn use the repository for these functions)? What would be the best way to do this? 回答1: What exactly do you mean by presentation layer? If you mean the Controller/Presenter, then it's

Entity Framework RC1 DbContext query issue

邮差的信 提交于 2019-12-07 21:08:06
问题 I'm trying to implement the repository pattern using entity framework code first rc 1. The problem I am running into is with creating the DbContext. I have an ioc container resolving the IRepository and it has a contextprovider which just news up a new DbContext with a connection string in a windsor.config file. With linq2sql this part was no problem but EF seems to be choking. I'll describe the problem below with an example. I've pulled out the code to simplify things a bit so that is why

Architecting ASP.net MVC App to use repositories and services

蹲街弑〆低调 提交于 2019-12-07 16:28:44
问题 I recently started reading about ASP.net MVC and after getting excited about the concept, i started to migrate all my webform project to MVC but i am having a hard time keeping my controller skinny even after following all the good advices out there (or maybe i just don't get it ... ). The website i deal with has Articles, Videos, Quotes ... and each of these entities have categories, comments, images that can be associated with it. I am using Linq to sql for database operations and for each