repository-pattern

IdentityUser in Data layer

我只是一个虾纸丫 提交于 2019-12-21 15:38:13
问题 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

A generic way to save an entity in Entity Framework

走远了吗. 提交于 2019-12-21 06:29:06
问题 I am trying to write a GenericEFRepository which will be used by other Repositories. I have a Save method as below. public virtual void Save(T entity) // where T : class, IEntity, new() And IEntity enforces long Id { get; set; } { var entry = _dbContext.Entry(entity); if (entry.State != EntityState.Detached) return; // context already knows about entity, don't do anything if (entity.Id < 1) { _dbSet.Add(entity); return; } var attachedEntity = _dbSet.Local.SingleOrDefault(e => e.Id == entity

Implementing the Repository Pattern in ASP.NET MVC

三世轮回 提交于 2019-12-21 04:25:12
问题 I am still having a hard time wrapping my head around this. I want to separate my layers (dlls) like so: 1) MyProject.Web.dll - MVC Web App (Controllers, Models (Edit/View), Views) 2) MyProject.Services.dll - Service Layer (Business Logic) 3) MyProject.Repositories.dll - Repositories 4) MyProject.Domain.dll - POCO Classes 5) MyProject.Data.dll - EF4 Workflow: 1) Controllers call Services to get objects to populate View/Edit Models. 2) Services call Repositories to get/persist objects. 3)

Using DbContext and DbSet instead of implementing repositories and unit of work

杀马特。学长 韩版系。学妹 提交于 2019-12-21 02:47:31
问题 I have seen plenty of articles about implementing repositories and a unit of work. I have also seen articles about how doing this is just adding extra complexity, because the DbContext is already using the repository and unit of work pattern. I will be refactoring an application that pretty much has a repository for each entity, and would like to remove as much complexity as possible. Can anyone explain/provide links to articles/blogs/etc that explain how to use the DbContext instead of my

How to map Entity Framework model classes with Business Layer class in n-tier architecture - ASP.NET-MVC

烈酒焚心 提交于 2019-12-21 02:36:07
问题 I am working on e-tier architecture within MVC framework (ASP.NET MVC5, Entity Framework 6). My application is divided into three sub-projects which are Business-Layer, Data-Access-Layer, Repository (This include repository and Unit of Work) and ASP.NET MVC web-app. I am struggling to understand mapping between business data and entity framework model. for example if I have model class User in entity framework as DAL - User Model [Table("User")] public class User { public User() { } [Key]

IAsyncRepository or IObservableRepository for silverlight 4 + WCF Data Services

末鹿安然 提交于 2019-12-20 14:44:38
问题 Update 2 : @Enigmativity has a brilliant answer. I've implemented this into a IObservableRepository<T> . Details in my answer below. Question: So I've changed most of the question (See edit history) I would just like it if someone commented/validated/puked on my design. =) So typically my Repos look like this: public interface IRepository<T> where T : class { T GetById(int id); IQueryable<T> GetAll(); void InsertOnSubmit(T entity); void DeleteOnSubmit(T entity); int SubmitChanges(); } But

Repository pattern - how to correctly handle JOINs and complex queries?

寵の児 提交于 2019-12-20 09:18:48
问题 I have a problem with Repository pattern - how to perform JOIN operations between several repositories. In this project, we use MVC, EF, DDD. I'm aware that this kind of question was here several times, I reference these questions later in this one. Between generic repository model (IRepository) and specific repository model, I chose specific option, since I consider ORM (in our case EF) as a generic repository pattern itself, so it doesn't make sense to add another generic repository and we

Bounded context implementation and design

╄→尐↘猪︶ㄣ 提交于 2019-12-20 09:04:21
问题 Let's say I have two bounded contexts, the Shipping Context and the Billing Context . Each of these contexts need to know about the customer. At a data level, the customer is represented by a CustomerTbl table in a database. This table consists of all the necessary columns that describe the customer. Columns in CustomerTbl (simplified): Name PhysicalAddress PaymentMethod The Shipping Context is concerned with Name and PhysicalAddress while the Billing Context is concerned with Name and

Generic Repository in Spring JPA

非 Y 不嫁゛ 提交于 2019-12-20 03:50:10
问题 We are working on a Restful project with lots of DB tables. Though the operations on the tables are almost same and mainly INSERT/UPDATE/DELETE/FETCH. my questions is: will we have to create a repository (extending JpaRepository) for every entity (Domain class) we create or, there is an option of creating a GenericRepository that can handle all the above-mentioned functionalities for all the entities? i.e a single GenericRepository for all. if so, could you share an example? 回答1: is [there]

Generic Repository, CreateObjectSet<T>() Method

帅比萌擦擦* 提交于 2019-12-20 01:34:35
问题 I was trying to implement a generic repository, and I have this right now: using System; using System.Collections.Generic; using System.Linq; using System.Data; using System.Data.Entity.Core.Objects; using Web_API.Models; namespace Web_API.DAL { class GenericRepository<T> : IRepository<T> where T : class { private ApplicationDbContext entities = null; IObjectSet<T> _objectSet; public GenericRepository(ApplicationDbContext _entities) { entities = _entities; _objectSet = entities