repository-pattern

ASP.NET Identity with Repository and Unit of Work

心不动则不痛 提交于 2019-11-27 09:38:12
问题 I'm learning Repository and Unit of Work patterns in ASP.NET MVC 5 application with Entity Framework 6. I had already read a lot of tutorials and articles, but almost all of them are condradictory. Ones say that Repository and Unit of Work patterns are good, others say DbContext is already a repository and unit of work, others say something similar, but offer a completely different approach. I tried all these different approaches (well, maybe not all of them) and still struggling regarding

Transactions in the Repository Pattern

我的梦境 提交于 2019-11-27 09:36:44
问题 How do I encapsulate the saving of more than one entity in a transactional manner using the repository pattern? For example, what if I wanted to add an order and update the customer status based on that order creation, but only do so if the order completed successfully? Keep in mind that for this example, orders are not a collection inside the customer. They are their own entity. This is just a contrived example, so I don’t really care whether orders should or should not be inside the

DDD - How to implement high-performing repositories for searching

落爺英雄遲暮 提交于 2019-11-27 09:28:11
问题 I have a question regarding DDD and the repository pattern. Say I have a Customer repository for the Customer aggregate root. The Get & Find methods return the fully populated aggregate, which includes objects like Address, etc. All good. But when the user is searching for a customer in the UI, I just require a 'summary' of the aggregate - just a flat object with summarised information. One way I could deal with this is to call the find method on the repository as normal, and then in the

What specific issue does the repository pattern solve?

我的未来我决定 提交于 2019-11-27 09:15:08
问题 (Note: My question has very similar concerns as the person who asked this question three months ago, but it was never answered.) I recently started working with MVC3 + Entity Framework and I keep reading that the best practice is to use the repository pattern to centralize access to the DAL. This is also accompanied with explanations that you want to keep the DAL separate from the domain and especially the view layer. But in the examples I've seen the repository is (or appears to be ) simply

How to use the repository pattern correctly?

孤街醉人 提交于 2019-11-27 08:58:49
问题 I am wondering how should I be grouping my repositories? Like from the examples I seen on the asp.net mvc and in my books they basically use one repository per database table. But that seems like a lot of repositories leading you to have to call up many repositories later on for mocking and stuff. So I am guessing I should group them. However I am not sure how to group them. Right now I made a registration Repository to handle all my registration stuff. However there are like 4 tables I need

Using Simple Injector with Unit Of Work & Repository Pattern in Windows Form

和自甴很熟 提交于 2019-11-27 07:30:51
I'm trying to implement IoC in my windows form application. My choice fell on Simple Injector, because it's fast and lightweight. I also implement unit of work and repository pattern in my apps. Here is the structure: DbContext : public class MemberContext : DbContext { public MemberContext() : base("Name=MemberContext") { } public DbSet<Member> Members { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();\ } } Model : public class Member { public int MemberID {

Repository design pattern

岁酱吖の 提交于 2019-11-27 06:54:42
问题 I have seen many repository pattern implementations. Specifically of 2 types They expose the generic repository which is queryable and expects a lamba expression from service class to get data from database. Write methods to get the data from database based on business requirements and encapsulate the logic (even lambda) of retrieving the data. Which one is a better approach? 回答1: I really prefer the second one. Even I've seen articles from top bloggers on .NET world, queryables, for me, are

Is it possible to remove child from collection and resolve issues on SaveChanges?

为君一笑 提交于 2019-11-27 06:45:50
We are using Entity Framework Code First with Foreign Key relationships. We investigating on ways on handling removing objects from an entities ICollection in our application. When we have an entity with child relationships we can add objects directly to their ICollection using Add method. Now when you use remove you get the error System.InvalidOperationException occurred Message=The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null

Entity Framework 6 Code First - Is Repository Implementation a Good One?

萝らか妹 提交于 2019-11-27 05:47:26
I am about to implement an Entity Framework 6 design with a repository and unit of work. There are so many articles around and I'm not sure what the best advice is: For example I realy like the pattern implemented here: for the reasons suggested in the article here However, Tom Dykstra (Senior Programming Writer on Microsoft's Web Platform & Tools Content Team) suggests it should be done in another article: here I subscribe to Pluralsight , and it is implemented in a slightly different way pretty much every time it is used in a course so choosing a design is difficult. Some people seem to

Entity Framework .Where nested in .Include

送分小仙女□ 提交于 2019-11-27 05:35:24
I'm attempting to perform a db lookup using EF5 code-first. The basic structure and table relationships are as follows; public partial class Member { public int RecordID {get; set;} public string Name {get; set;} ...etc. public virtual ICollection<MemberLink> MasterLinks {get; set;} public virtual ICollection<MemberLink> SlaveLinks {get; set;} public virtual ICollection<Message> ReceivedMessages {get; set;} public virtual ICollection<Message> SentMessages {get; set;} } public partial class MemberLink { public int RecordID {get; set;} public virtual Member MasterMember {get; set;} public