repository-pattern

What type to return when querying multiple entities in Repository layer?

被刻印的时光 ゝ 提交于 2019-12-04 19:32:42
问题 I have the following layers involved in this question: Service Layer (Using IoC to call Repository) Domain Model (POCO / Domain Entities, defined repository Interfaces) Repository Layer (EF .edmx and implemented repositories) A lot of times it's really straight forward: Repository layer queries database via Entity Framework and returns IList<SomeDomainEntity> to caller which was Service Layer. The type returned is a type defined in the Domain Model. The problem I'm running into is when I need

Fetching Strategy example in repository pattern with pure POCO Entity framework

百般思念 提交于 2019-12-04 19:24:21
I'm trying to roll out a strategy pattern with entity framework and the repository pattern using a simple example such as User and Post in which a user has many posts. From this answer here , I have the following domain: public interface IUser { public Guid UserId { get; set; } public string UserName { get; set; } public IEnumerable<Post> Posts { get; set; } } Add interfaces to support the roles in which you will use the user. public interface IAddPostsToUser : IUser { public void AddPost(Post post); } Now my repository looks like this: public interface IUserRepository { User Get<TRole>(Guid

Design for multi-tenant app using SOA, UoW, Repository, DataContext & multiple databases

六月ゝ 毕业季﹏ 提交于 2019-12-04 19:02:38
Let me start by apologizing for the length of this post but I wanted to provide as much detail as possible to increase the chance of an answer. Thanks in advance. I’m adding new features to an existing application that integrates data from several databases. In short, it allows clients and/or their accountants to access and update financial information about their locations. The application has 3 tiers with a web client (I’m looking to replace this will a Silverlight client very soon), a service layer running on an app server and the database tier. When I took ownership, the application,

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

两盒软妹~` 提交于 2019-12-04 18:16:26
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 IUnitOfWork interface. I'm actually using .net 3.5, not 4.0. My basic Data Access constructor looks like this: public DataAccessLayer(IUnitOfWork unitOfWork, IRealtimeRepository realTimeRepository) { this.unitOfWork = unitOfWork; this.realTimeRepository =

How can I activate a Service outside Activity correctly?

橙三吉。 提交于 2019-12-04 17:56:44
I am trying to build an app that will rely on a Webservice to work. To make it, I decided to follow the Model-View-ViewModel architecture together with the Repository pattern. I try to make this architecture inspired by the guidelines shown in Guide to App architecture , from Android Developer's Official Site. I use OkHttp library to consume the WebService, and Room for the phone's database. I made some testing to see if the app obtained succesfully the Data through the Webservice, from inside the Main Activity, and it worked; the App received successfully the Data. ServiceConnection

How to use Entity Framework context with dependency injection?

我是研究僧i 提交于 2019-12-04 17:48:06
I'm trying to setup a base Repository class that can use the Entity Framework edmx model context. The problem I'm having is that I need to find an interface that the EF EDMX object context implements so I can pass to the constructor via dependency injections. I've got around this before by using a DataFactory that creates it and stores it in the HttpContext but that kills the ability to unit test. Any help would be appreciated. Thanks! public abstract class BaseRepository<T> where T : EntityObject { private MyDataModelContext _dataContext; private ObjectSet<T> dbset; protected BaseRepository

Pros and cons of DDD Repositories

妖精的绣舞 提交于 2019-12-04 17:28:23
问题 Pros: Repositories hide complex queries. Repository methods can be used as transaction boundaries. ORM can easily be mocked Cons: ORM frameworks offer already a collection like interface to persistent objects, what is the intention of repositories. So repositories add extra complexity to the system. combinatorial explosion when using findBy methods. These methods can be avoided with Criteria objects, queries or example objects. But to do that no repository is needed because a ORM already

How to do branching approach for multiple sites?

泪湿孤枕 提交于 2019-12-04 17:20:47
I'm new to git and would want to know if this branching approach would be okay for what we intended to do. We'll have three sites prod.websitename.com - live site sandbox.websitename.com - testing site that can be used by our clients dev.websitename.com - internal site for developing and testing hotfix/features before pushing to live site What we intend to do is to have a single centralized repository that would serve all three sites. The repository will have three branches: master, sandbox, and development and then we'll just checkout the branch to change files and pull/push the changes for

Entity Framework Service Layer Update POCO

南楼画角 提交于 2019-12-04 16:38:51
I am using the Service Layer --> Repository --> Entity Framework (Code-First) w/POCO objects approach, and I am having a hard time with updating entities. I am using AutoMapper to map my Domain Objects to my View Models and that works good for getting the data, no how do I get that changes back into the database? Using pure POCO objects, I would assume that there is no sort of change tracking, so I see my only option is to handle it myself. Do you just make sure that your View Models have the EXACT same properties as your Domain Objects? What if I just change a field or two on the View Model?

IRepository confusion on objects returned

天涯浪子 提交于 2019-12-04 15:57:05
问题 I have some e-commerce code that I use often that uses Linq To SQL for saving orders to the database. I want to remove the tightly coupled Linq to SQL bit and pass in an IRepository instead but I am still a little confused on things. Say I have a GetCustomer() method on my ICustomerRepository that returns a Customer object. Do I need it to really return an ICustomer object that gets passed back from that method so if I switch from Linq To SQL to say SubSonic it's not a problem? I believe I do