repository-pattern

Advice With Repository/Service Layer Design Pattern

Hi Guys, Trying to make a really simple repository and service layer pattern here. (.NET 4, C#, LINQ, although this question is partially language-agnostic). Note: this is just R&D. My goal is to minimize the amount of method definitions in my service layer. Here's my Repository Contract: interface IFooRepository { IEnumerable<Foo...

MVC Repository Pattern/Web Services SoC Question

Hello, I am new to ASP.NET MVC and I am trying to implement best practices for a small-to-mid size application that uses a web service as its data source. The web service exposes the following methods to support the application: AuthenticateCustomer - returns the customer ID if valid email/password GetCustomer - returns a serialized ...

Clarification in dealing with collections with the repository pattern

If you have two repositories dealing with persistance to a relational DB, a personrepository that deals with "Person" objects, and an addressrepository which deals with "Address" objects, and a person object has a collection of addresses (probably lazy loaded). Obviously the personrepository would be used to persist changes to the person...

How can I refactor this IQueryable<T> Repository Method?

Hi Guys, I'm working on a .NET 4 application, C#, Entity Framework 4, SQL Server 2008. I have a 7 tables in my database, each representing a specific level of location (Country, State, City, Neighborhood, etc). Now in my Repository I am trying to define an interface contract which has only one Find() method. To do this, I've created ...

C#: How to create a generic superclass to be extended by non-generic subclasses

I have a bunch of Repository classes which all look a bit like the following. Note that I have omitted certain methods; I just want you to get a flavour. public class SuggestionRepository : ISuggestionRepository { private IUnitOfWork _unitOfWork; public SuggestionRepository(IUnitOfWork unitOfWork) { _unitOfWork = un...

C#: Generic implementation of method doesn't satisfy interface.

In this post I talked about using a generic base class to enable me to create repository classes without duplicating loads of basic plumbing code. Each Repository is accessed through an interface. In the code below, I will only show one of the methods for the sake of brevity: Interface: IQueryable<Suggestion> All { get; } Generic ba...

Why does ObjectContext class not derive from some Interface ?

I consider folks at MS way more smarter than I am. I was trying to build/test a repository which almost follows this approach except that I want to loosely couple the ObjectContext dependency inside the repository. I found out that in order to do decouple this I need to jump a lot of hoops as shown in this article.Even this approach is d...

Domain Design class decisions

I am creating a simple web site to get more familiar with MVC 2.0. I've been doing web forms since 1.0 and getting ready to start a major overhaul of a web forms site to MVC. So want to build a smaller app to work out the learning curve. So I'm going to build a time tracking application. I'm using ASP.NET MVC 2.0 and LINQ to SQL. I pl...

Implement repository service in java

I want to have a repository of Url to music(audio and video) with different file types (mp3,ogg,flv,avi) which can be used as a web-service. Is there a free or open source solution for a repository (for example written in Java) which could help me, or do you have some recommendations, or patterns that could help me? ...

ASP.Net MVC Repository Question

I have 4 different models that I'm pulling information from for a grid in a view. This code excerpt is apart of my controller for my Index action. Each Model has a repository, partRepository, parts_comboRepository, vendor_partRepository, and manufacturer_partRepository, and i use those repositories to grab data for my joins. ...

Confusion over IRepository

I'm a bit confused about when using the "IRepository pattern", when actually to load the data. Currently I have something like this: public class MainViewModel : ViewModelBase { // EF4 generated ObjectContext private ScorBotEntities context = new ScorBotEntities(); // Custom IUserRepository class private IUse...

Working with Symfony and Git (collaboration)

Hello everyone, Suppose we have a Project with three applications — A, B and C. Our team: Jack, Susan and Martin. And one project leader — David. Each programmer is working on their own application: A - Jack B - Susan C - Martin So, there is a problem with source code management. How to effectively organize it with G...

Problem updating through LINQtoSQL in MVC application using StructureMap, Repository Pattern and UoW

I have an ASP MVC application using LINQ to SQL for data access. I am trying to use the Repository and Unit of Work patterns, with a service layer consuming the repositories and unit of work. I am experiencing a problem when attempting to perform updates on a particular repository. My application architecture is as follows: My service ...

entity framework + repository + unit or work question

I'm thinking about starting a new project using EF 4 and going through some articles, I found an article about EF with repository pattern and unit of work (http://blogs.msdn.com/b/adonet/archive/2009/06/16/using-repository-and-unit-of-work-patterns-with-entity-framework-4-0.aspx) Looking at that article, it uses the ObjectContext as the...

Constructor error in WCF service implemented with Repository and UnitofWork patterns.

I have a WCF service which implemented using Repository and UnitofWork patterns. And now I am getting following error: The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to t...

Entity Framework Generic Repository Context

I am building an ASP.NET 4.0 MVC 2 app with a generic repository based on this blog post. I'm not sure how to deal with the lifetime of ObjectContext -- here is a typical method from my repository class: public T GetSingle<T>(Func<T, bool> predicate) where T : class { using (MyDbEntities dbEntities = new MyDbEntities()) { ...

Repository Pattern and Data Access

Hello All, I am trying to get into a project with ASP.NET MVC and NHibernate ( Newbie) and looking for faster data access from DAL. my solution will be roughly asp.net mvc ------ Business Layer - DataAccess Layer ----------All supported by Infrastructure layer ---------------- My project is to do with classifieds and community s...

Appropriate lifecycle for repository classes using Castle Windsor

When I started with Windsor I thought DI would be simple. Now it's causing me more and more confusion. A repository strikes me as a class with a singleton lifecycle. I should have a single instance of a FooRepository to load and save Foos to the database during the application's lifetime. However, each repository holds a reference to a...

Repository pattern with a WCF Rest Service and returning IQUERYABLE using LINQ to OBJECTS?

Hi there, i wish to create a repository pattern but with a WCF Rest Service which controls the data access. Can anyone confirm or help with my thinking / config. ASP.NET Controllers call to service (not rest service but service of a repository pattern) Repository Pattern Service >> calls to repository Repository >> calls to WCF Rest S...

ASP.NET MVC using the Repository Pattern

Currently im using EF and using its datacontext directly in all of my actions, but since i started reading about loose coupling and testability im thinking that thats not the best way to go. Im trying to understand all the pro's and con's before i start refactor all my current code. Problem 1: Considering that every entity needs its own...