repository-pattern

DDD - the rule that Entities can't access Repositories directly

自作多情 提交于 2019-11-26 21:09:35
In Domain Driven Design, there seems to be lots of agreement that Entities should not access Repositories directly. Did this come from Eric Evans Domain Driven Design book, or did it come from elsewhere? Where are there some good explanations for the reasoning behind it? edit: To clarify: I'm not talking about the classic OO practice of separating data access off into a separate layer from the business logic - I'm talking about the specific arrangement whereby in DDD, Entities are not supposed to talk to the data access layer at all (i.e. they are not supposed to hold references to Repository

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

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 20:04:25
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? Ladislav Mrnka 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 the point of Generic repository in EF 4.1 Challenges with testable and mockable code in EF

Generic Repository for SQLite-Net in Xamarin Project

不打扰是莪最后的温柔 提交于 2019-11-26 19:09:33
问题 I am wondering if there is a way to write a generic repository for my Xamarin project versus writing a different Repository for each entity in my object. The Xamarin Tasky Pro example have one Repository for the Task entity because that is the only entity it has. In my own project I have more than one Entity, so my question is how can I make the following Customer Repository to become generic so that the ProductManager, EmployeeManager, etc can use it. If you know of an example or a blog post

Repository pattern and mapping between domain models and Entity Framework

只愿长相守 提交于 2019-11-26 18:53:55
问题 My repositories deal with and provide persistence for a rich domain model. I do not want to expose the anemic, Entity Framework data entity to my business layers, so I need some way of mapping between them. In most cases, constructing a domain model instance from a data entity requires the use of parameterised constructors and methods (since it is rich). It is not as simple as a property/field match. AutoMapper could be used for the opposite situation (mapping to data entities) but not when

Generate POCO classes in different project to the project with Entity Framework model

佐手、 提交于 2019-11-26 18:41:42
I'm trying to use the Repository Pattern with EF4 using VS2010. To this end I am using POCO code generation by right clicking on the entity model designer and clicking Add code generation item. I then select the POCO template and get my classes. What I would like to be able to do is have my solution structured into separate projects for Entity (POCO) classes and another project for the entity model and repository code. This means that my MVC project could use the POCO classes for strongly typed views etc and not have to know about the repository or have to have a reference to it. To plug it

Join or Mutible DBContext Repository Generic c#

左心房为你撑大大i 提交于 2019-11-26 18:41:02
问题 I have repository generic where I do method as Get,Update,Insert. I get a data from table in data base I use this method. public IEnumerable<typeEntity> Get<typeEntity>(Expression<Func<typeEntity, bool>> newObjectEntity,int page, int rowsByPage) where typeEntity : class { List<typeEntity> Result = null; Result = Context.Set<typeEntity>().Where(newObjectEntity).OrderBy(m => true).Skip<typeEntity>(5 * (page - 1)).Take<typeEntity>(rowsByPage).ToList<typeEntity>(); return Result; } I when get

LINQ to SQL and the repository pattern

半世苍凉 提交于 2019-11-26 17:54:47
问题 I feel like I'm running around in circles. I can't seem to make up my mind as to what the right repository pattern is using LINQ to SQL. If you're familiar with Rob Conery's MVC Storefront you will see that his implementation wraps the LINQ-generated models with another class and treats the LINQ-generated one simply as a data transfer object (DTO). It looks something like this: //Custom wrapper class. namespace Data { public class Customer { public int Id {get;set;} public string Name {get

Why is PerThreadLifetimeManager used in this example?

我的梦境 提交于 2019-11-26 17:51:32
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 below I'm wondering why I should use the PerThreadLifeimeManager? I am using an ASP.NET web forms project

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

十年热恋 提交于 2019-11-26 16:57:30
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 forever and ever and it depends on different applications. Whats I like to know, would this approach be

Where to convert business model to view model?

依然范特西╮ 提交于 2019-11-26 15:55:38
问题 In my ASP.NET MVC application, I am using unit of work and repository patterns for data access. Using the unit of work class and the repository defined inside it I am fetching the related set of entities in my controller. With my beginner knowledge, I can think of two ways to fetch the business model and convert it to view model. Repository returns the business model to controller, this model than mapped to view model, or Repository itself converts business model to view model and then it is