repository-pattern

Shared repositories in repository pattern

六月ゝ 毕业季﹏ 提交于 2019-12-04 11:19:11
Repository dependency? Lets say I have a domain that looks like the following: public class User { public int UserId { get; set; } public Lazy<Post> Posts { get; set; } } public class Post { public int PostId { get; set; } public User Poster { get; set; } } A user with my posts. How do I set up my repository so that for every user , it returns a list of Post and for every post , I get the Poster ? I have 2 repositories: public class UserRepository : IUserRepository { public IQueryable<User> GetUsers(); } public class PostRepository : IPostRepository { public IQueryable<Post> GetPosts(); } I

ASP.NET MVC & Repository Pattern Understanding

廉价感情. 提交于 2019-12-04 11:01:11
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 work and I want to make sure I get the major points I ask you to point out any glaring (not anal or

ASP.NET MVC using the Repository Pattern

淺唱寂寞╮ 提交于 2019-12-04 11:00:54
问题 Currently im using EF and using its datacontext directly in all of my actions, but since i started reading about loose coupling and testability im thinking that thats not the best way to go. Im trying to understand all the pro's and con's before i start refactor all my current code. Problem 1: Considering that every entity needs its own repository, and thus has to setup its own connection to a datasource (lets assume a database using EF), wouldnt that give alot of overhead if i need data from

Examples of Repository Pattern with consuming an external REST web service via HttpClient?

六眼飞鱼酱① 提交于 2019-12-04 10:42:02
问题 I've searched around quite a bit, but haven't found any good examples of consuming an external REST web service using a Repository Pattern in something like an ASP.NET MVC app, with loose coupling and meaningful separation of concerns. Almost all examples of repository pattern I find online are writing SQL data or using an ORM. I'd just like to see some examples of retrieving data using HttpClient but wrapped in a repository. Any references to good examples? Or could someone write up a simple

Repository Pattern without an ORM

匆匆过客 提交于 2019-12-04 08:57:23
问题 I am using repository pattern in a .NET C# application that does not use an ORM. However the issue I am having is how to fill One-to-many List properties of an entity. e.g. if a customer has a list of orders i.e. if the Customer class has a List property called Orders and my repository has a method called GetCustomerById, then? Should I load the Orders list within the GetCustomerById method? What if the Order itself has another list property and so on? What if I want to do lazy loading? Where

Using the Generic repository/Unit of work pattern in large projects

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 08:45:11
问题 I'm working on a quite large application. The domain has about 20-30 types, implemented as ORM classes (for example EF Code First or XPO, doesn't matter for the question). I've read several articles and suggestions about a generic implementation of the repository pattern and combining it with the unit of work pattern, resulting a code something like this: public interface IRepository<T> { IQueryable<T> AsQueryable(); IEnumerable<T> GetAll(Expression<Func<T, bool>> filter); T GetByID(int id);

.NET RIA Services with MVC Style Repositories?

我的未来我决定 提交于 2019-12-04 08:28:23
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) is only really documented with the Entity Framework - you can find some info on Linq2Sql and even less

Laravel ioc automatic resolution - works from controller but not from custom class

半城伤御伤魂 提交于 2019-12-04 08:02:50
Namespaces omitted for brevity... I have written the following service provider and registered in config/app.php: class OfferServiceProvider extends ServiceProvider { public function register() { $this->registerLossControlManager(); } protected function registerLossControlManager() { $this->app->bind('LossControlInterface', 'LossControl'); } } Here is my LossControlInterface interface LossControlInterface { /** * @param int $demandId * @param float $offerTotal * @param float $productTotal * @param null|int $partnerId * @return mixed */ public function make($demandId, $offerTotal, $productTotal

How can I write a clean Repository without exposing IQueryable to the rest of my application?

人走茶凉 提交于 2019-12-04 07:48:07
问题 So, I've read all the Q&A's here on SO regarding the subject of whether or not to expose IQueryable to the rest of your project or not (see here, and here), and I've ultimately decided that I don't want to expose IQueryable to anything but my Model. Because IQueryable is tied to certain persistence implementations I don't like the idea of locking myself into this. Similarly, I'm not sure how good I feel about classes further down the call chain modifying the actual query that aren't in the

IdentityUser in Data layer

好久不见. 提交于 2019-12-04 07:45:50
I am struggling with my design (or over-design) of a web project I am doing. I have a MyProject.Data, MyProject.Business, and MyProject.Web DLL's. My data layer (EF6 based) contains my entities, db context. My business layer contains my repositories (yeah maybe not a true repo pattern). I have added IdentityFramwork to the Web Project, and of cource it creates ApplicationUser. I already have a User POCO in my Data layer. I would like to move the Application user into the Data layer, so I can use it in conjunction with other entities. One way to do this is have my Data.User extend IdentityUser,