repository-pattern

how to use Repository pattern to make it easy switch between ORMs?

I knew than one of the benefits from using repository pattern make it easy to switch between ORM, for example will implement data access code using Linq to sql and also using Ado.net entity framework, then using Dependency injection switch which one to use. I saw KIGG doing the same "but its class diagram is complicated a little, at lea...

How to test Repository Pattern with ADO.NET Entity Framework?

While using Repository pattern I find it difficult to understand the reason of designing the software with TDD technique while in reality you will have to implement the Interface for your repository in your persistence dataset. To make my point clear I will submit an example: I have the following Interface on my domain model: public i...

Testing Real Repositories

Hi, I've set up unit tests that test a fake repository and tests that make use of a fake repository. But what about testing the real repository that hits the database ? If this is left to integration tests then it would be seem that it isn't tested directly and problems could be missed. Am I missing something here? ...

how to design Repository pattern to be easy switch to another ORM later?

I am new to repository pattern but i tried, my goal is to make a design which will let me easily with just some few edits "dependency injection, or configuration edits" to be able to switch to another ORM without touching other solution layers. I reached this implementation: and here is the code: public interface IRepository<T> { T ...

Questions regarding Entity Framework + DDD

I'm having a difficult time finding straight forward examples of using EF in a DDD style pattern. This is also my first time employing DDD and have a few questions regarding solution layout and how to employ some of the DDD patterns. 1) Most of the examples I've seen regarding using the Repository pattern w/ EF just show specialized Mod...

LINQ Gernic List VB.NET

Hi Guys, I am trying to create a domain model using a product class entity an Abstract repository and a fake repository with sample data. I have created the following product class Namespace Entities Public Class Product Dim _ProductID As Integer Dim _Name As String Dim _Description As String Dim _Price As Decimal D...

How much resposibility should my repository/service have?

Hey! I have the following objects: Person <- Contact -> ClientsPerson <- Client I'm using the repository pattern with a service layer. But already here, being a perfectionist, I'm lost! I also have a PersonService, ClientService and I'm pretty sure I need to have a ContactService which should call the personService.Add(person) and cl...

Books that will cover TDD, DDD and Design Patterns in .NET

I would like to get book(s) that will really give me a complete view of modern ASP.NET development using C#, TDD, ASP.NET MVC, DDD and Design Patterns such as the Repository pattern. I'm very competent with C# and ASP.NET MVC, but want to fill in the gaps. If you've had a good experience with a book or two that covers these topics coul...

How closely aligned is the Repository patten with either Unit of Work or ActiveRecord

Although I'm not doing full blown DDD, I find the repository pattern appealing and I do try to segment the repositories along aggregate-root boundaries. I'm implementing repositories on top of the Entity Framework, and here the ObjectContext allows for a unit-of-work style as it tracks changes to the entities and will generate the appro...

Where/How do I handle different connection types using Repository Pattern with ADO.Net?

I am new to the repository pattern but am creating a repository to connect to two different database types that have the same data structure. Where and how should I handle the connection? Here are my requirements/constraints/project description I will be connecting to SQL Server 2005 and DB2 (on Iseries) I will be using the repository...

What's the right way to Load child collections inside a POCO with a SubSonic Repository?

I've read the questions asking about the right way to inject data access into POCOs, and the consensus seems to be "don't". Fine, what is the right way then? If I have an Order object, and I want a list of the OrderLines, I don't want to explicitly assign that list to the POCO externally, that's horribly ugly. So if I can't use DI to giv...

Placing Business Rules inside a Repository

I have a table that is storing a list of rules. In my code, I need to retrieve those rules and maintain the list of rules (via. the Repository Pattern) so that I can reuse them. I then need to generate(business logic) a list of objects based on the rules for a particular period of time, eg, a list of holiday objects filtered by the rul...

Where do I put business logic when I'm using the repository pattern?

Hi, I am using the Repository Pattern for my application. I have a class User. User is identified by Email. The UserRepository contains a method CreateUser(User user). There is a business rule saying that users should have a unique Email. I want to implement a transaction which first checks whether an email is in use and if not, the u...

Eager loading and repository pattern

I'm wondering how to properly handle eager-loading problem for complex object graphs when using Repository pattern. This isn't ORM specific problem i guess. First try: public interface IProductRepository : IRepository<Product> { Product GetById(int id); IProductRepository WithCustomers(); } This would work fine, but that would in...

Repository pattern in c#

How to implement repository pattern in C#.net 2.0? Just show me the basic structure. Coz we don't have DataContext in .net 2.0. ...

Repository pattern with Linq to SQL using IoC, Dependency Injection, Unit of Work

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 so...

what is the best practice to use for repository when you need to do expensive retrieval

Ok, lets say i have a DataRepository class with the methods, getNames() and getStates(). lets say this data is stored in a webservice or database that is an expensive operation. once the first query is run and returned, when a consumer asked for these methods its returned immediately as the results are cached in the DataRepository clas...

Repository Pattern and Entity Framework

Hi I looked at lot of examples online using Repository Pattern with EF. But none of them really talked about working with Related Entities. Like say User can have multiple addresses. IUserRepository User CreateUser(); void UpdateUser(); Now if I were to add a Address to the User should, should it be on the Repository? OR on the Use...

Should a Repository be responsible for "flattening" a domain?

Disclaimer: I'm pretty new to DDD and its associated terminology, so if i'm mislabeling any concepts, please correct me. I'm currently working on a site with a relatively simple domain model (Catalog items, each of which stores a collection of CatalogImage items.) My repository follows the standard interface of FindbyID(int ID) GetA...

Is this Repository pattern efficient with LINQ-to-SQL?

I'm currently reading the book Pro Asp.Net MVC Framework. In the book, the author suggests using a repository pattern similar to the following. [Table(Name = "Products")] public class Product { [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)] public int ProductId { get;...