repository-pattern

UOW + Repository + Autofac load two different DbContext

柔情痞子 提交于 2019-12-06 07:00:02
问题 I'm facing an issue today and I'm unable to solve it, I searched a lot and can't get into a solution, please help me if you can. I'm implementing a MVC application which uses EF + Repository Pattern + Unit Of Work with Autofac as the Dependency Injector. I was able to work with one DbContext class, but I'm facing a situation where I need to use another DbContext instance (which access another database with another user credentials) Let me explain better: I have EntityA which comes from

Generics and Entity Framework: How do I return a different type depending on a column value

风格不统一 提交于 2019-12-06 06:43:44
问题 We have a Persons table which stores different types of persons (Buyer, Seller, Agent, etc). Our ORM is Entity Framework CodeFirst (CTP5). We're using the repository pattern for good TDD and mocking. In the PersonRepository I want to return a specific type so I can do things like this: Agent a = repository.Get<Agent>(5005); // Where 5005 is just an example Id for the person a.SomeAgentProperty = someValue; Buyer b = repository.Get<Buyer>(253); // Again, a simple PersonId. b.SomeBuyerProperty

Good repository pattern for asp.net mvc

蹲街弑〆低调 提交于 2019-12-06 06:43:39
问题 I have implemented a repository pattern in my asp.net mvc web application... But i want to know is this a good repository pattern or still can i improve it more... using System; using System.Collections.Generic; using System.Linq; using System.Web; using TaxiMVC.BusinessObjects; namespace TaxiMVC.Models { public class ClientRepository { private TaxiDataContext taxidb = new TaxiDataContext(); Client cli = new Client(); //Get all Clients public IQueryable<ClientBO> FindAllClients(int userId) {

Can repository pattern be used for loading of “partial entities”

倖福魔咒の 提交于 2019-12-06 06:13:44
I'm trying to get better understanding of repository pattern in Domain Driven Design. All examples of repository pattern implementation are dealing with entities only. But what if i need to retrieve only some part of entity? For example, i have Client entity with large amount of properties. Can i define something like this in ClientRepository: public IEnumerable<string> GetClientsNames() { ... } of even: class ClientBaseInfo //includes some subset of properties of Client entity { public string Name {get; set;} public string Surname {get; set;} public int Age {get; set;} public string Email

ASP.NET MVC & Repository Pattern Understanding

末鹿安然 提交于 2019-12-06 05:06:51
问题 So I'm extremely new to ASP.NET MVC and Interface design. I've been asking a lot of questions and reading a lot of articles trying to make sense of it all. Due to a crisis at work, I have been called upon to do my best and learn this environment. And although it's been frustrating to grasp, I am slowly getting it. I have created an image in photoshop that shows my basic understanding of how the Repository Pattern works and why it's very much recommended. I'm trying to deploy this pattern at

Architecting ASP.net MVC App to use repositories and services

僤鯓⒐⒋嵵緔 提交于 2019-12-06 03:47:15
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, Quotes ... and each of these entities have categories, comments, images that can be associated with it. I am using Linq to sql for database operations and for each of these Entities, i have a Repository, and for each repository, i create a service to be used in the

how to design Repository pattern to be easy switch to another ORM later?

纵然是瞬间 提交于 2019-12-06 03:36:22
问题 I am new to repository pattern but i tried, my goal is to make a design which will let me easily with just some few edits "dependency injection, or configuration edits" to be able to switch to another ORM without touching other solution layers. I reached this implementation: and here is the code: public interface IRepository<T> { T Get(int key); IQueryable<T> GetAll(); void Save(T entity); T Update(T entity); // Common data will be added here } public interface ICustomerRepository :

.NET RIA Services with MVC Style Repositories?

心不动则不痛 提交于 2019-12-06 02:10:48
问题 I have a Solution with several projects in it, including two asp.net mvc projects that share a Repositories and Models that live in a external assembly (also in the same solution). Essentially... Core/ -Repositories -Models Domestic.Web/ -Basic MVC Site, references the core project International.Web/ -Basic MVC Site, references the core project What I want to do is build a Silverlight 3 / RIA Services application for all the database admin. Thats fine except RIA Services (for the most part)

Possible to use the Repository Pattern + Stored Procedures ? Should / can they return IQueryable?

▼魔方 西西 提交于 2019-12-06 00:17:16
I'm a big fan of using the Repository pattern to return IQueryable<T> objects. I then let my services layer determine what does what (eg. filter by XXX, order by YYY, project into ABCD, etc). But I've got some hardcore DB stuff, so I've got it all wrapped up into a Stored Procedure . Works fine. I know EF can execute stored procs .. but I'm not sure how this fits into a Repository Pattern data layer. Does anyone have any examples / suggestions ? Do i let the repository method execute the stored procedure, and then i return the result (eg. ICollection<Foo> as AsQueryable .. so the service layer

Repository + UnitOfWork pattern for entity framework

烈酒焚心 提交于 2019-12-05 21:56:52
问题 I was searching the net up and down and I didn't manage to find a suitable design for my application. I am looking for Repository+UnitOfWork pattern that will manage connections and dispose them automatically when done. I need to support both web application where each request will have its own UnitOfWork and windows application where each thread will have its own UnitOfWork. I need the patters to dispose automatically the UnitOfWork whrn request/thread is done. I also would like to support