Repository Pattern and Entity Framework.

Posted by vitorcast on Stack Overflow See other posts from Stack Overflow or by vitorcast
Published on 2010-04-13T19:14:58Z Indexed on 2010/04/13 19:23 UTC
Read the original article Hit count: 978

Hi people,

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 class Product with a property that map wich Order that Product relates itself.

So I create my Repository pattern like IReporitory with the basic CRUD operations and inside my controllers I implement the ProductRepository or OrderRepository.

The problem occurs when I try to create Product and have to assign my Order on it, like ProductOne.Order = _orderRepository.Find(orderId);

That operation gave me some strange behavior and I can't find out what is wrong with it.

Thanks for the help.

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about mvc