repository-pattern

Using Entity Framework with repository pattern in WinForms MDI

Hi, We are about to start up a new project similar to a previous one. I could just copy the old design but I am not all too satisified with the old design. It is a "standard" business system (sales,stocktaking,warehousing etc) built ontop of .Net 3.5 (Winforms MDI) with Entity Framework in the backend. All forms inherit from a basefo...

Foreign tables in SQL Server updated with Primary Key

The title might be a little misleading because I didn't really know what to call it. Here is my dbml and I am using the repository pattern to communicate between my application layer and my SQL layer. As you can see, I have four tables. Three of them have a foreign key to ContactId. I used this method because I need to store an "array", ...

Not sure how to use Dependency Injection + Repository Pattern + Unit Of Work Pattern with a WinForm application.

(apologies for the Wall Of Text... :) ) Summary Using Dependency Injection with my Winfor application is creating a large number of Repository Context's. I'm not sure if the way i'm using this is right or wrong, or what the common practice is. Details In the last 6 odd months, I've been making ASP.NET MVC applications that impliment...

Need advice on complex insert scenario using LinqToSql with repository pattern

I have a User table and a ClubMember table in my database. There is a one-to-one mapping between users and club members, so every time I insert a ClubMember, I need to insert a User first. This is implemented with a foreign key on ClubMember (UserId REFERENCES User (Id)). Over in my ASP.NET MVC app, I'm using LinqToSql and the Repositor...

Repository and Service Design question

We are trying to find out the best practice when using DDD and we are having some discussions on what makes the most sense or is the "right way". Note: All code is pseudo code. Conceder the following: public interface IDomainEntityAService { void CreateMyObject(DomainEntityA myobject); DomainEntityA RetrieveDomainEntityA(long ...

Another repository-pattern question: how to deal with domain model projections?

Hi all, I've read a lot about repository pattern implementation and I still can't find out how should I implement entity projections querying? For example I have large and complex product entity, but I want to display only product's name and it's id. Where should i implement this projection? In my entity repository or in a caller code?...

Does it make sense to create a repository that takes a default search criterium as constructor argument?

I'm refactoring a website I build. It's a website for a travel agency. I'm thinking of implementing the repository pattern. The travel agency has two divisions, that have their own website and target different groups of customers. The backend however is the same for both websites. They both access the same DB tables. Some tables simply ...

Should there be a Service Layer in Asp.net mvc?

Should there be a Service Layer in Asp.net MVC between Controller and Repository? As Repository is there for only Data Access. Some business logic is leaked into Controller. This might create a problem if the same operation is used by classic Asp.Net client as we have to duplicate the logic in Controller. ...

Repository Pattern and multiple related core entities or business objects - one repository or more?

Hi, I am looking at implementing the repository pattern (since what I came up with was 90% an implementation of it anyway), and have come across a design question - where I have two or more core business objects (for example, Business and Contact in a CRM app), the BO's can be strongly related or not related at all. In this situation, ...

How to create a fake repository with a 1-to-many association for MVC

I'm trying to create a fake repository for unit testing with a class object that has a one to many relationship. I'm using ASP.NET MVC and Linq to SQL. My reference is Steven Sanderson's "Pro ASP.NET MVC Framework" book. I've created the Entity Classes with the association: [Table(Name = "Albums")] public class Album { [Column(Is...

Specific generic interfaces

I'm refactoring all my repository interfaces of various types. Most of them contain very similar methods like Add, Update but some have methods which only makes sense for a specific type. This is a best practices question. I thought about using generics to straighten things up. public interface IRepository<T> { T Get(int id); ...

Asp.net MVC with mysql

I am using ASP MVC to develop a new project. I am using the repository pattern for Data Access. I have worked on the same scenario before using SQL Server, but now I'm using MySQL. How do I interact with MySQL using the repository pattern? ...

Creating Entity Framework objects with Unity for Unit of Work/Repository pattern

I'm trying to implement the Unit of Work/Repository pattern, as described here: http://blogs.msdn.com/adonet/archive/2009/06/16/using-repository-and-unit-of-work-patterns-with-entity-framework-4-0.aspx This requires each Repository to accept an IUnitOfWork implementation, eg an EF datacontext extended with a partial class to add an IUni...

What kind of events should be created for a CRUD application?

I have an application that is centered around a database (ORM is LINQ-SQL) that has a table called Assignment. I am using the repository pattern to manipulate the database. My application is basically going to perform CRUD operations. I am new to delegates and events and I am asking you what events I should create (like maybe AssignmentC...

MVC repository pattern design decision

I have an asp .net MVC application and recently started implementing the repository pattern with a service validation layer, much like this. I've been creating one repository/service for each model that I create. Is this overkill? Instead, should I create one repository/service for each logical business area that provides CRUD for many ...

ASP.NET MVC - Should I use the Repository Pattern to write ViewModels to the database or convert them to Models first?

In my ASP.NET MVC app, I have a fairly complex edit page which combines a number of models into one view. I'm using the ViewModel pattern to combine all of this information and present one cohesive object to the View. As an example, my ViewModel structure is something like this: CompanyId CompanyName List<Employee> Employees List<Cont...

Confused about Linq to SQL and repositories

For the last 4 years I have been working as an ASP.NET developer in a small company where all applications are built using the Smart UI anti-pattern in .NET 2.0. This means I have no experience with .NET 3.5 and things like LINQ and general concepts like repository and service layers. I realize that in order to find a new job, I need to ...

Accessing other tables/object from my Repository

I have created myself a typed repository interface IRepository that has methods defined such as Save, Delete, FindById, FindAll etc I then created a concrete class Repository that implements all these methods using: _context.GetTable(typeof(TEntity). I can than create my CustomerRepository like so: public class CustomerRepository : Re...

Generate POCO classes in different project to the project with Entity Framework model

I'm trying to use the Repository Pattern with EF4 using VS2010. To this end I am using POCO code generation by right clicking on the entity model designer and clicking Add code generation item. I then select the POCO template and get my classes. What I would like to be able to do is have my solution structured into separate projects fo...

How should I be using IoC in this winform piece of code?

Hi folks, I've got a winform app in visual studio 2010. My app does the following Get a list of files which I need to read the data then insert into a database. For each file, read data and insert into DB. So .. this is the code i have. // ******* // *** How should the _repository be Injected?? // ******* var list = _repository.Get...