repository-pattern

Unit of work and the repository pattern

I have a repository pattern setup using NHibernate. The base class looks like this: public interface IUnitOfWork : IDisposable { void Commit(); void Rollback(); } // generic NHibernate implementation of IUnitOfWork here public class NHibernateRepositoryBase<T> : IRepository<T> { private NHibernateUnitOfWork _unitOfWork; ...

Bind WPF control to SQL server through repository pattern

How can I bind a wpf control to a SQL Server property. Like say a Listbox <ListView> <ListView.View> <GridView> <GridViewColumn Header="Name"> <GridViewColumn Header="Date Assigned"> <GridViewColumn Header="Date Due"> </GridView> </ListView.View> ...

DDD - How to implement performant repositories for searching.

Hello, I have a question regarding DDD and the repository pattern. Say I have a Customer repository for the Customer aggregate root. The Get & Find methods return the fully populated aggregate, which includes objects like Address, etc. All good. But when the user is searching for a customer in the UI, I just require a 'summary' of the ...

Architecture abstraction problem in Repository ASP.NET MVC

Hi. I'm working with MVC ASP.NET 3.5 SP1 on VS2008. I'm looking for a way to abstract this three methods I have in my Users repository. public User GetUser(Log log) { return db.Users.FirstOrDefault(u => u.Logs.Any(l => l.id.Equals(log.id))); } public User GetUser(Product product) { return db.Users.FirstOrDefault(u => u.Products.Any...

Aggregate roots. How far does the rabbit hole go.

I'm trying to use the Repository pattern for my current project and i'm currently in the process of trying to model the domain and find the aggregate roots. I've read of the 'Cascading Delete' rule which states that if it doesn't make sense to delete a member when the root is deleted then it shouldn't be part of the root. I'll use a P...

Help designing my own rough DataContext

Hi All I've done a bit of Linq programming with TDD ASP.Net MVC and loved it. Digressing, I'm now learning webforms against stored procs and cannot use linq. I would like to retain some of the loose coupling and testability enjoyed with MVC. I didn't have the time to learn and setup a dependency injection infrastructure so instead ...

object reference is not set to an instance of an object repository

I am getting an XAMLParseException that is really covering up another exception. Here is part of the stacktrace: Message=Object reference not set to an instance of an object. Source=AssignmentOrganizer StackTrace: at AssignmentOrganizer.MainWindow..ctor() in C:\Users\Mohit\Documents\Visual Studi...

NHibernate - Sorting Entities based on Property/Column + how to manage?

I'm writting an ASP.NET MVC e-commerce app using NHibernate and I want the end-user to be able to control the ordering of Product Categories (not just have them appear alphebetically etc.). Normally, I'd add an OrderIndex/Sort column (of type int) to the Category table, and property to the Category domain class. But the problem is in ha...

LINQ, repository pattern and many-to-many relations

Hello, I've a problem with saving changes to database, I'm using LINQ2SQL mapping. I've implemented M:M relation (User <= UserRole => Role) based on tutorial: http://www.codeproject.com/KB/linq/linqtutorial2.aspx#premain25 Everything works fine when I'm using one class which is inherits from DataContext and is responsible for all of m...

Repository taking linq expression for filtering

I am considering refactoring a repository I have to improve its flexibility and reduce the method count. Where there are the following methods: Collection GetAllUsersByRole(Role role) User GetUserByuserName(string userName) ...I would like to have a single method taking a Linq expression: ICollection GetUsers(Expression e) { //ret...

Using Repository Pattern, POCOs and LINQtoSQL with tables of multiple types

Firstly, my previous question will help give some back story. As stated in that question, I have a super-type table (if that is the technical term for it) and I have multiple sub-types in different tables - all with field unique to that sub-type. Events * Id * EventTypeId * AllEventTypes_Field EventType0 * EventId (FK) * EventType0_Fi...

LightSpeed with IoC/Dependency Injection using Repository Pattern

Does anyone have an example of using LightSpeed with the Repository Pattern using interfaces and dependency injection? ...

Repository Pattern in C#

I am trying to figure out the repository pattern for .NET. I think I have a pretty decent understanding of it, but I still don't feel comfortable using it. I have googled for this topic, but found some advanced topics along with the repository pattern. What I am looking for is a basic knowledge of the concept, then I can build on it. ...

Pros and cons of having static repositories in ASP.NET MVC application

Hello everybody, What are the pros and cons of using static repositories in an ASP.NET MVC application? Wouldn't it be better to have all the methods available all the time -> means that the class get's instantiated only once instead of having multiple controllers referencing to the same repository class and its methods? Or do I get s...

Should Service Depend on Many Repositories, or Break Them Up?

I'm using a repository pattern for my data access. So I basically have a repository per table/class. My UI currently uses service classes to actually get things done, and these service classes wrap, and therefore depend on repositories. In many cases my services are only dependent upon one or two repositories, so things aren't too crazy....

Update ListView's ItemsSource Constantly?

I have a ListView that I set it's ItemsSource to list all the Assignments (a table in my SQL Database, ORM is LINQ to SQL) like so: ltvAssignments.ItemsSource = _repo.ListAssignments(); (This bit of code is exactly after InitializeCompenent() is called) And for the heck of it, I added a sample: Assignment sample1 = new Assignment() ...

DDD: Getting aggregate roots for other aggregates

I've been studying DDD for the past 2 weeks, and one of the things that really stuck out to me was how aggregate roots can contain other aggregate roots. Aggregate roots are retrieved from the repository, but if a root contains another root, does the repository have a reference to the other repository and asks it to build the subroot? ...

Managing Transactions either in service layer or repository layer ???

Hi, I have a certain scenario where inserts and updates are done on multiple tables based on some constraints ..so its natural to use Transaction scope for these scenarios.Now,I have a respository layer and a service layer. service layer mediates the repository and the UI and is persistent ignorant. Now i m confused where to use the tran...

ASP.NET splitting out membership and using the repository pattern

Hi, I am building an application using asp.net mvc, DI, IoC, TDD as a bit of a learning exercise. For my data access I am using the repository pattern. Now I am looking at membership and how this can work with the repository pattern. I am currently using a Linq to Sql repository but don't want to be tied to SQL Server for membership. ...

Some Issues about Rob Conery's repository pattern !

Hi, I'm trying to apply repository pattern as Rob Conery's described on his blog under "MVC Storefront ". But i want to ask about some issues that i had before i apply this Design pattern. Rob made his own "Model" and use some ORM "LinqToSql" to mapp his database and then he used some interfaces and custom Repositories on top of these...