repository-pattern

Difference between the Repository Pattern and the View Model Pattern

I am trying to create a site using the ASP MVC Framework. Some of the documentation use the IRepository pattern to abstract the information being sent to the view for rendering, while others recommend using a ViewModel (as in MVVC). What is the difference? Aren't these the same concept? Thanks in advance ...

Architecting ASP.net MVC App to use repositories and services

Hello, I recently started reading about ASP.net MVC and after getting excited about the concept, i started to migrate all my webform project to MVC but i am having a hard time keeping my controller skinny even after following all the good advices out there (or maybe i just don't get it ... ). The website i deal with has Articles, Videos,...

c#Repository pattern: One repository per subclass?

I am wondering if you would create a repository for each subclass of a domain model. There are two classes for example: public class Person { public virtual String GivenName { set; get; } public virtual String FamilyName { set; get; } public virtual String EMailAdress { set; get; } } public class Customer : Person { ...

How to make a Generic Repository?

Hi I am wondering if anyone has any good tutorials(or maybe even a library that is already made and well documented) on making a generic repository. I am using currently linq to sql but it might change so I don't know if you can make a generic repository that would take little to no changes if I would say switch to entity framework. T...

Time to start returning IQueryable<T> instead of IList<T> to my Web UI / Web API Layer?

I've got a multi-layer application that starts with the repository pattern for all data access and it returns IQueryable to the Services layer. The Services layer, which includes all of the business logic, returns IList to the Controllers (note: I'm using ASP.NET MVC for the UI layer). The benefit of returning IQueryable in the data ac...

How should I handle this Optimistic Concurrency error in this Entity Framework code, I have?

Hi folks, I have the following pseduo code in some Repository Pattern project that uses EF4. public void Delete(int someId) { // 1. Load the entity for that Id. If there is none, then null. // 2. If entity != null, then DeleteObject(..); } Pretty simple but I'm getting a run-time error:- ConcurrencyException: Store, Update...

WCF Rest services for use with the repository pattern?

Hi there, I am considering moving my Service Layer and my data layer (repository pattern) to a WCF Rest service. So basically i would have my software installed locally (WPF client) which would call the Service Layer that exists via a Rest Service... The service layer would then call my data layer using a WCF Rest Service also OR maybe...

Saving complex aggregates using Repository Pattern

We have a complex aggregate (sensitive names obfuscated for confidentiality reasons). The root, R, is composed of collections of Ms, As, Cs, Ss. Ms have collections of other low-level details. etc etc R really is an aggregate (no fair suggesting we split it!) We use lazy loading to retrieve the details. No problem there. But we are s...

Using Repository and Unit of Work patterns with Entity Framework 4.0 and MVC 2

Hi, I'm following this article Using Repository and Unit of Work patterns with Entity Framework 4.0. I'm tying to implement the Repository and Unit of work pattern, using Asp.Net MVC 2 and Entity Framework 4. Please let me know if I'm doing it right... In the Models folder: Northwind.edmx Products.cs (POCO class) ProductRepository....

In a DDD approach, is this example modelled correctly?

Just created an acc on SO to ask this :) Assuming this simplified example: building a web application to manage projects... The application has the following requirements/rules. 1) Users should be able to create projects inserting the project name. 2) Project names cannot be empty. 3) Two projects can't have the same name. I'm using...

Using a Generic Repository pattern with fluent nHibernate

I'm currently developing a medium sized application, which will access 2 or more SQL databases, on different sites etc... I am considering using something similar to this: http://mikehadlow.blogspot.com/2008/03/using-irepository-pattern-with-linq-to.html However, I want to use fluent nHibernate, in place of Linq-to-SQL (and of course n...

nHibernate session - Using repository pattern in Web, windows, wcf etc...

I recently posted a question which was answered by Bryan Watts, regarding generic repository for nHibernate. I'm trying to design my data access to allow various facets - from ASP.net, WCF and Windows Forms / Windows services. I'm a bit confused re: session management etc.. How would I handle this? I've been checking out code such a...

Using a nHibernate wrapper with fluent nHibernate

Is it possible to use something like this wrapper with fluent configuration? http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/ If so, where would I add the fluent config? Also, would this be suited to use in both asp.net and windows applications? I'm planning to use the repository patte...

refactor LINQ TO SQL custom properties that instantiate datacontext

I am working on an existing ASP.NET MVC app that started small and has grown with time to require a good re-architecture and refactoring. One thing that I am struggling with is that we've got partial classes of the L2S entities so we could add some extra properties, but these props create a new data context and query the DB for a subset...

Repository Pattern and Entity Framework.

I want to make an implementation with repository pattern with ASP.NET MVC 2 and Entity Framework but I have had some issues in the process. First of all, I have 2 entities that has a relationship between them, like Order and Product. When I generate my dbml file it gaves me a class Order with a property that map a "ProductSet" and one ...

Repository Pattern with Entity Framework 3.5 and MVVM

I am developing a Database File System. I am using - .Net framework 3.5 Entity Framework 3.5 WPF with MVVM pattern The project spans across multiple assemblies each using same model. One assembly,let's call it a "server", only adds data to the database using EF i.e. same model.Other assemblies (including the UI) both reads and wri...

get Generic CRUD operation in EF

Hello, Is there any way or design pattern can I use to get Generic CRUD operations? Because I’m working on n-tire application using EF in the data layer and I don’t want to use CRUD Functions in Every Entities. Your help would be appreciated ...

Repository pattern - Switch out the database and switch in XML files

Repository pattern - Switch out the database and switch in XML files. Hello I have an asp.net MVC 2.0 project and I have followed the Repository pattern. Periodically, I am losing access to the database server so I want to have another mechanism in place (XML files) to continue developing. It is not possible to have a local version of...

Using C# and Repository Factory and the error: The requested database is not defined in configuration ? What causes that?

I am using Repository factory for visual studio 2008 for a personal project. It generated a class called ProductRepository which inherits from Repository<Product>. The ProductRepository has a constructor which gets a database name as string and passes it to its base (I mean Repository<Product> ). When I try to debug my project step by s...

Arranging VS2008 generated LinqToSql/EntityFramework data models/contexts in assemblies.

What pattern should I use for data-access in case of VS2008 generated L2s or EF DataModels? Repository-pattern or what? As we know VS2008 generates Data-Models and DataContexts/ObjectContexts in the same file, then, how should I arrange my VS2008 assemblies in my VS2008 solution to achieve a layered design? If I use repository pattern,...