repository-pattern

Is the Repository Pattern the same as the Asp.net Provider Model?

烈酒焚心 提交于 2019-12-05 01:30:53
Since Asp.net 2.0, there is the Provider Model. On the implementation detail, a provider is class derived from ProviderBase which is an abstract class rather than an interface, but anyway the Provider Model is there so that we can have different implementation to swap in the out by just editing the web.config. For example if you create a blog app, you may have a BlogProvider : ProviderBase, then you can have implementations of BlogProvider like: SqlBlogProvider, OracleBlogProvider and even MockBlogProvider for testing. Now, Repository Pattern is getting popular, and I feel it is to satisfy the

How to make a Generic Repository?

我的梦境 提交于 2019-12-05 01:10:36
问题 I am wondering if anyone has any good tutorials(or maybe even a library that is already made and well documented) on making a generic repository. I am using currently linq to sql but it might change so I don't know if you can make a generic repository that would take little to no changes if I would say switch to entity framework. Thanks I think I should also add why I want a generic repository. The reason is in my database I have like corporate tables(users who's subscriptions are paid by

Repository pattern with Entity Frameworks 4

谁都会走 提交于 2019-12-05 01:09:51
问题 I used to use NHibernate with repository interfaces. What is the proper way to use this pattern with EF? How can I implement this repository interface, for a RepositoryBase<T> ? public interface IRepository<T> { T GetById(object id); void Save(T entity); T[] GetAll(); void Delete(T entity); } 回答1: For some reason all of the examples given expose the collections as IQueryable or IEnumerable. EF4 has an interface for this very purpose - IObjectSet (or IDbSet if you're using the latest CTP).

Spring with Neo4j, GraphRepository<?> vs handmade interface

别等时光非礼了梦想. 提交于 2019-12-05 00:54:30
问题 I found out that there is an interface called GraphRepository. I have a repository for users implementing a homemade interface that does its job, but I was wondering, shouldn't I implement GraphRepository instead ? Even if it will be quite long to implement and some methods will be useless, I think it is a standard and I already re-coded a lot of methods that are defined in this interface. So should I write "YAGNI" code or not respect the standard ? What is your advice ? 回答1: you don't need

Still lost on Repositories and Decoupling, ASP.NET MVC

北战南征 提交于 2019-12-04 22:36:52
问题 I'm still on my eternal quest to build (and understand) modern programming convention of decoupling, IoC, DI, etc. I'm to the part where I am trying to figure out how to build a repository. I've examined the post at Database abstraction layer design - Using IRepository the right way? which was very helpful, but I've still got some problems that are just befuddling me all the way. I have my program in now 4 layers... Web (Project | ASP.NET MVC Application) - References Models.dll and

How to make a repository for class with <T> in EF

百般思念 提交于 2019-12-04 21:46:55
I have a simple class: public class TestClass<T> { public int ID { get; set; } public T Value { get; set; } } Is is possible to use EF Code First and Repository pattern to save this kind of elements to SQL database? Edit : It seems like the DbSet's cannot be created using the -notation. E.g. public class UnitOFWorkTestContext : DbContext { ... public DbSet<TestClass<int>> TestClass_Int { get; set; } ... } Gives error: The type 'UnitOFWorkTest.Models.TestClass`1[System.Int32]' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute

What is best practise for repository pattern - repo per table?

大城市里の小女人 提交于 2019-12-04 21:25:57
问题 The repository pattern seems to work well when working with an initial project with several large main tables. However as the project grows it seems a little inflexible. Say you have lots of child tables that hang off the main table, do you need a repository for each table? E.g. CustomerAddress Record has following child tables: -> County -> Country -> CustomerType On the UI, 3 dropdown lists need to be displayed, but it gets a bit tedious writing a repository for each of the above tables

Repository pattern with generics and DI

纵然是瞬间 提交于 2019-12-04 19:44:50
I have a base repository contract which other contracts extend, like follows public interface IBaseRepository<T> where T : class { IList<T> GetContents(); } and then there are other contracts which extend it like follows public interface IRepository1 : IBaseRepository<MyClass1> { } public interface IRepository2 : IBaseRepository<MyClass2> { } I implement IRepository1 as follows public class Repository1 : IRepository1 { public IList<MyClass1> GetContents() { //some code goes here } } similarly for IRepository2 public class Repository2 : IRepository2 { public IList<MyClass2> GetContents() { /

linq2sql, repository pattern - how to query data from two or more tables?

放肆的年华 提交于 2019-12-04 19:41:47
I use Repository pattern (and linq2sql as data access) and have, for example, ProductsRep and CustomersRep. In very simple scenario db has two tables - Produsts (ProductID, CustomerID, ProductName, Date) and Customer (CustomerID, FirstName, LastName). Each repository provide methods to create, update, delete and get specific model object, and, may be, some filters. But if I want to query all customers that buy specific product by product name, I have to get ProductID of this product using ProductsRep and then get all customers that buy product with this id using CustomersRep. Am I right? This

best practice to implement repository pattern and unitOfWork in ASP.NET MVC [closed]

落爺英雄遲暮 提交于 2019-12-04 19:39:08
Closed . This question is opinion-based . It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed 5 years ago . I am working on implementing Repository Pattern and UnitOfWork from last few days, which I have completed to upto good extend, I believe. I am sure there are plenty of ways to implement that but what I am interesting to find best approach for that. I am taking very simple example coded in ASP.NET MVC 5 using visual studio 2013. my main focus of question is implementation of