irepository

Are we all looking for the same IRepository?

I've been trying to come up with a way to write generic repositories that work against various data stores: public interface IRepository { IQueryable<T> GetAll<T>(); void Save<T>(T item); void Delete<T>(T item); } public class MemoryRepository : IRepository {...} public class SqlRepository : IRepository {...} I'd like to w...

How can I use Expression<T> in NHibernate?

I have read the very good blog post of Rob Conery Crazy Talk: Reducing ORM Friction How can I generalize this interface so I can implement it with NHibernate? using System; using System.Collections; using System.Linq; using System.Linq.Expressions; public interface IRepository<T> { IQueryable<T> GetAll(); Pag...

IRepository confusion on objects returned

I have some e-commerce code that I use often that uses Linq To SQL for saving orders to the database. I want to remove the tightly coupled Linq to SQL bit and pass in an IRepository instead but I am still a little confused on things. Say I have a GetCustomer() method on my ICustomerRepository that returns a Customer object. Do I need...

How To Write CRUD Unit Tests for Moq and Linq-to-Sql

I am just getting involved in Moq and unit testing, so forgive me if this seems obvious (a quick search through SO didn't show me anything like this). I have an interface with the following proposed member: void AddFeed(Feed feed); That I would like to write a unit test for this functionality. The test class has a Moq Repository decl...

Repository and Immutable objects?

I may be doomed by an impedence mismatch, but I'm trying to reconcile examples I've seen for IRepository and immutable objects. I'm working on a cataloging application where hundrds of web requests operate on a 'working set' of products - a subset of the whole catalog tends to be in play at any given time. At the same time, our data te...

IRepository pattern in a client server application

Hi, using the IRepository pattern is really convenient in a single tier app (web app, rich client), but how to use this pattern in a distributed application? I should probably implement an IRepository, which will delegate everything to the server (probably using WCF) anyone has any experience in this? thanks in advance, Erik. ...

IRepositories Join in Subsonic

Hi i'm stuck with this doubt: How do I make i Join with 2 IRepositories? look my controller... public ActionResult Colaboradores(int baseid) { IRepository<Colaborador> _repocolab = new SubSonicRepository<Colaborador>(); IRepository<Usuario> _repouser = new SubSonicRepository<Usuario>(); return View(); ...

concrete sense of IRepository<T> vs Repository if I do not do unit tests with mocks

Hello all, I have this: public interface IRepository<T> where T : class { void Delete(T entity); void Add(T entity); void Attach(T entity); void Detach(T entity); void SaveChanges(); } now for every of my Entity I make concrete classes implementing the generic IRepository => public class SchoolclassRepository : I...

What's the correct way to instantiate an IRepository class from the Controller?

I have the following project layout: MVC UI |...CustomerController (ICustomerRepository - how do I instantiate this?) Data Model |...ICustomerRepository DAL (Separate Data access layer, references Data Model to get the IxRepositories) |...CustomerRepository (inherits ICustomerRepository) What's the correct way to say ICustomerReposi...

Am I using IRepository correctly?

I'm looking to use the IRepository pattern (backed by NHibernate, if it matters) in a small project. The domain is a simple one, intentionally so to allow me to focus on understanding the IRepository pattern. The lone domain class is Movie, with properties for Year, Genre, and Title. My intent would be to "get" movies whose properties m...

What's the Oracle equivalent of System.Data.Linq.DataContext?

I am implementing the IRepository interface against an Oracle database. public interface IDinnerRepository { IQueryable<Dinner> FindAllDinners(); IQueryable<Dinner> FindByLocation(float latitude, float longitude); IQueryable<Dinner> FindUpcomingDinners(); Dinner GetDinner(int id); void Add(Dinner dinner...