repository-pattern

Possible to use the Repository Pattern + Stored Procedures ? Should / can they return IQueryable?

霸气de小男生 提交于 2019-12-22 11:12:14
问题 I'm a big fan of using the Repository pattern to return IQueryable<T> objects. I then let my services layer determine what does what (eg. filter by XXX, order by YYY, project into ABCD, etc). But I've got some hardcore DB stuff, so I've got it all wrapped up into a Stored Procedure . Works fine. I know EF can execute stored procs .. but I'm not sure how this fits into a Repository Pattern data layer. Does anyone have any examples / suggestions ? Do i let the repository method execute the

EF4: how to use a generic repository pattern ?

孤者浪人 提交于 2019-12-22 09:38:25
问题 I'm trying to streamline my existing repos by using a generic repo I can subclass from. The problem is that I can't figure out how to write a few of my base class methods. I currently have: public interface IRepository<T> : IDisposable where T : class { IQueryable<T> GetAll(); T GetSingle(int id); T GetSingle(string slug); void Save(T entity); } public class HGRepository<T> : IRepository<T> where T : class { protected HGEntities _siteDB; protected IObjectSet<T> _objectSet; public HGRepository

“Session is Closed!” - NHibernate

ⅰ亾dé卋堺 提交于 2019-12-22 05:18:48
问题 This is in a web application environment: An initial request is able to successfully complete, however any additional requests return a "Session is Closed" response from the NHibernate framework. I'm using a HttpModule approach with the following code: public class MyHttpModule : IHttpModule { public void Init(HttpApplication context) { context.EndRequest += ApplicationEndRequest; context.BeginRequest += ApplicationBeginRequest; } public void ApplicationBeginRequest(object sender, EventArgs e

How to use Order By in this MSDN example

纵然是瞬间 提交于 2019-12-22 03:58:18
问题 I'm trying to figure out how to use this orderBy parameter. I am not sure what I am suppose to pass in. http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application public virtual IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = "") { IQueryable<TEntity> query = dbSet; if (filter !=

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

风流意气都作罢 提交于 2019-12-22 01:05:04
问题 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

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

假装没事ソ 提交于 2019-12-22 00:37:42
问题 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 6 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

How to use Entity Framework context with dependency injection?

偶尔善良 提交于 2019-12-21 22:04:14
问题 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 :

Repository Pattern in Layered Architecture

[亡魂溺海] 提交于 2019-12-21 21:45:27
问题 I've gone through quite a few articles on the repository pattern and had some questions. I'm trying to implement this in a ASP.NET 4.0 application. The architecture is a layered architecture with a Presentation Layer, Business Layer and Data Layer. From this article, http://www.primaryobjects.com/CMS/Article108.aspx I have created the MYSQLRepository (DataLayer) public class MySQLRepository:IOrderRepository { public List<Order> GetOrders() { List<Order> orders = new List<Order>(); orders.Add

DDD/CQRS confusion regarding ReadModels and the Domain

你。 提交于 2019-12-21 20:45:14
问题 So after much reading I've now come to the realization that complex reporting functions do not belong in your typical Repository and that there needs to be some kind of dedicated "Finder" which returns read only objects to be used in reporting. What I'm unclear on is where the "Finder" classes, as well as their associated ReadModel classes are supposed to go inside my project? Are the finders like repositories in that you have an interface for the finder inside the infrastructure assembly

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

穿精又带淫゛_ 提交于 2019-12-21 17:05:05
问题 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 *