repository-pattern

How would I design a repository to handle multiple data access strategies?

别等时光非礼了梦想. 提交于 2020-01-12 06:24:18
问题 What would a skeleton design look like for a repository able to support multiple database layers using ASP.NET MVC and C#? I want to see what a design would look like if I support both LINQ to SQL and NHibernate. How would I create my database object, and call a method on it in my BLL layer? 回答1: The repository pattern is probably the best solution for this. You would define an interface for each repository, then create concrete repositories for Linq2Sql and NHibernate implementations, e.g.

How would I design a repository to handle multiple data access strategies?

佐手、 提交于 2020-01-12 06:23:28
问题 What would a skeleton design look like for a repository able to support multiple database layers using ASP.NET MVC and C#? I want to see what a design would look like if I support both LINQ to SQL and NHibernate. How would I create my database object, and call a method on it in my BLL layer? 回答1: The repository pattern is probably the best solution for this. You would define an interface for each repository, then create concrete repositories for Linq2Sql and NHibernate implementations, e.g.

How to implement a generic RepositoryFactory?

为君一笑 提交于 2020-01-12 03:41:25
问题 I'm trying to implement a Generic Repository. This is what I've got so far ... public interface IRepositoryFactory { IRepository<T> RepositoryOf<T>() where T : class; } public class EntityFrameworkRepositoryFactory : IRepositoryFactory { private readonly IWindsorContainer _container; public EntityFrameworkRepositoryFactory(IWindsorContainer container) { _container = container; } public IRepository<T> RepositoryOf<T>() where T : class { var repository = _container.Resolve<IRepository<T>>();

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:

Repository Pattern: how to Lazy Load? or, Should I split this Aggregate?

老子叫甜甜 提交于 2020-01-11 14:49:06
问题 I have a domain model that has the concept of an Editor and a Project. An Editor owns a number of Projects, and a Project has not only an Editor owner, but also a number of Editor members. Therefore, an Editor also has a number of "joined" Projects. I am taking a DDD approach to modelling this and using the Repository pattern for persistence. However, I don't grok the pattern well enough yet to determine how I should do this. I'm working on the assumption that Editor and Project are

ASP.NET MVC Patterns

拟墨画扇 提交于 2020-01-11 06:43:21
问题 I am fairly new to MVC, but after playing with it (MVC 3/Razor), I am hooked. I have a few questions: 1) What is the best, or most widely used pattern to develop MVC apps in? Repository, DDD, UOW? 2) I am using the Entity Framework 4, so could some please explain to me or point me to a good source that will explain the Repository Pattern w/EF4? Doesn't EF4 take place as the business layer and the data access layer? Does the Repository Pattern even provide a benefit? 3) Also, one last question

What exactly is the difference between a data mapper and a repository?

主宰稳场 提交于 2020-01-10 07:22:46
问题 Well I've been trying to find out the difference between data mapper and repository, but up to now I still have not. It seems to me that the expert programmer said "Repository is another layer of abstraction over the mapping layer where query construction code is concentrated". It seems understandable but is still somewhat very abstract. I read this article on stackoverflow before, and it just made me even more confused: How is the Data Mapper pattern different from the Repository Pattern? I

Repository / IQueryable / Query Object

喜欢而已 提交于 2020-01-10 07:22:13
问题 I am building a repository and I've seen in many places 2 reasons not to expose IQueryable outside the repository. 1) The first is because different LINQ providers could behave differently, and this difference should be contained within the repository. 2) The second is to prevent service level developers from modifying the database query such that it accidentally causes performance issues. I guess issue 2 can only be prevented by keeping all query logic within the repository and not allowing

RESTful and Repository returning values from another type architecture

跟風遠走 提交于 2020-01-07 03:10:29
问题 In short, I have two database tables: Languages and Frameworks. The important thing is that there is one-to-many relation between the tables(one language has many frameworks). I am designing a RESTful(WebAPI2) service to consume the information from these tables. I am using the repository pattern. Using EF, I've made a navigational property for the language to reach its frameworks. However, how should that be implemented in the repositories. Is it correct to return a framework collection in

Asp.Net MVC3 adding search functionality

删除回忆录丶 提交于 2020-01-06 13:09:00
问题 I am trying to implement search functionality on a list of customers, the functionality is detailed in this tutorial on the Asp.Net site, http://www.asp.net/entity-framework/tutorials/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application In my controller i have the following public ViewResult Index(string sortOrder, string searchString) { ViewBag.CustomerNameSortParm = String.IsNullOrEmpty(sortOrder) ? "CustomerName desc" : ""; ViewBag.PrimaryContactNameSortParm