repository-pattern

Store Changes to Domain Model

Hi all, I have following problem and I am not sure how to go about it: We have a given "marked" state of the domain objects (which is made persitent in a database). Driving away from this "marked" state the user is allows to make several changes to the domain object but if he wants to he is allowed to revert back to the last "marked" s...

ASP.net MVC 2 Application Tutorial using Entity Framework with many Tables

I am a newbie to ASP.net & MVC 2, and have understood the basic concepts of how views, routes and controllers are implemented in it. Having great trouble with the MVC 2 "Models" though because I have always avoided ORM's. Please point me to some good ASP.net MVC web application tutorials that use ADO.net Entity Framework with many table...

Pattern for client-side update in SOA

I want to develop a data-driven WPF application, which uses WCF to connect to the server-side, which itself uses NHibernate to persist data. For examle there is a domain-object called "Customer" and there is also a flattened (with Automapper) "CustomerDTO" which is returned by a WCF-operation called "GetCustomer(int customerId)". I don'...

pass parameter to repository while maitaining separation of concerns

Hi all. I'm new to mvc and this whole way of programming is pretty unfamiliar for me, so be gentle ... I have in my article repository: public IQueryable<Article> GetArticles(int? category, int? position) { return from a in dc.Articles where a.LanguageIndex == lang && a.CategoryIndex == category && a.ArticlePosition == p...

LINQ to entities - best practices for passing models

As we all know most apps have a data access layer, often using repository classes. Typically we want the repository to operate with strongly typed objects, e.g. interface IUserRespository { User GetUserByID(int id); void AddUser(User u); ... and so on } However, sometimes we want to make a more complex query on a DB, ...

scoping NHibernate ISession in a spawned Thread with NInject

Ok, here's the scenario. I have an ASP.NET site that periodically spawns a background thread to do some jobs. the thread's execution consists of a JobRunner that iterates through a list of IJobs and calls Execute() on each one. JobRunner and each IJob is created by NInject. A couple of the IJobs have a dependency to IRepository<Model...

Repository Pattern: How many repositories are needed to get a Contact with two Addresses?

If you have one Contact, with a 1:* relationship with Addresses, and possibly one or more other tables used to hold the persisted value objects -- how many repositories should there be? Should there be just one ContactRepository with one public method (GetContact(), that internally calls a private method (GetAddresses)) that returns a...

Using repository pattern in ASP.NET MVC with a SQL Server DB; how to mock repository so its unit testable without breaking OOD

I've been learning the ASP.NET MVC framework using the Apress book "Pro ASP.NET MVC Framework" by Steven Sanderson. To that end I have been trying out a few things on a project that I am not that familar with but are things that I thing I should be doing, namely: Using repository pattern to access my database and populate my domain/bus...

Good repository pattern for asp.net mvc...

I have implemented a repository pattern in my asp.net mvc web application... But i want to know is this a good repository pattern or still can i improve it more... using System; using System.Collections.Generic; using System.Linq; using System.Web; using TaxiMVC.BusinessObjects; namespace TaxiMVC.Models { public class ClientRepos...

How to configure Ninject for ASP.NET MVC using LinqToSQL and Repository Pattern

I have done some searching around but have not been able to figure out how to bind LinqToSql data context's with specified connection strings into different repositories. This binding is performed in global.ajax when routes are registered. I'm using a fairly standard repository pattern to decouple the LinqToSql infrastructure from my ap...

NHibernate : pattern for returning fully loaded instances from repositories

Hi all As part of my endless NHibernate-inspired DAL refactoring purgatory, I have started to use the Repository pattern to keep NHibernate at arms length from my UI layer. Here's an example of a Load method from a repository. public StoredWill Load(int id) { StoredWill storedWill; using (ISession session = NHibernateSessionFactory...

What is the 'best way' or 'best practise' for communicating errors to the View from a service layer in MVC2?

I had issued with using a ModelStateWrapper in MVC 1 as described here: http://www.asp.net/mvc/tutorials/validating-with-a-service-layer--cs As much as I was able to test my application it still felt like there was a dependency/circular reference with the ModelState, the controller and the service layer. With the new DataAnnotation in M...

WPF Prism Entity Frameword repository

Hi., I am a bit lost. Im building a WPF application using the PRISM guidance, I want to use the Entity Framework 4 for a data repository. I have previously developed a Silverlight app. using Prism and WCF RIA Services which worked great as all my components is decoupled. So what is the best way of getting data in my WPF application in...

Translators from the data layer on

Currently working on a project, new product, using MVC. I've written a few of these, and I've found doing a repository pattern with "specialized" generic services (GetObjectService< T >, UpdateObjectService< T >, etc). This allows for those special instances of "hey, I need to get something based on this stuff" that's fairly complex an...

How to pass unit of work container into constructor of repository using dependency injection

I'm trying to work out how to complete my implementation of the Repository pattern in an ASP.NET web application. At the moment, I have a repository interface per domain class defining methods for e.g. loading and saving instances of that class. Each repository interface is implemented by a class which does the NHibernate stuff. Castle...

Getting Started with Repository Pattern

I'm trying to get started with the repository pattern and ASP.NET MVC, and I can't help but believe I'm missing something. Forgive me if this is a stupid question, but it seems to me like an implementation violates DRY exponentially. For example, in my (admittedly novice) understanding in order to implement this, I would have to: Cre...

What are the differences between Active Record and Repository pattern?

It seems to me that the only difference is that Active Record has CRUD methods in data container class, and the Repository pattern uses separate class for data container and CRUD methods, but surely I'm wrong. What are the differences between Active Record and Repository pattern? When should I use which pattern? ...

Displaying data objects mapped by ID elegantly in views

I have a bunch of support Cases and Users. Each Case is assigned to a User with a unique ID. My data model represents this with an AssignedUser user ID reference. This is easy to store and retrieve, but not convenient to display. When I want to display a list of Cases, the user property should be formatted as the user's username and not...

Problem With Repository Pattern & Abstract Classes

Hi Guys, Come across a problem with the repository pattern combined with the use of abstract classes. I have a repository which implements a single method returning an ICollection of an abstract type. Here's my abstract class: public abstract class Location { public abstract string Name { get; set; } public abstract LocationTyp...

Repository pattern, explicit or implicit save?

Hello, It's a weird question I know :) I really like to do the things in the right way and I have a doubt. I know about making a interface, using DI... My question is: Is better to have a method like "SaveChanges" that you have to call manually everytime you add / delete / whatever an object?: _repo.Add(blah); _repo.SaveChanges(); ...