repository-pattern

How to inject dependencies using Ninject In ASP.NET WebForm?

给你一囗甜甜゛ 提交于 2019-12-01 08:02:51
I have a fair idea of using the Repository Pattern and have been attempting to "upgrade" our current way of creating ASP .Net websites. So i do the following Create a solution with a class project called DataAccessLayer and another class project called BusinessLogicLayer . Finally a 3rd project which is my ASP .Net website (a normal site). I add a dbml file to the DAL and drag a table, then in my BLL i add an interface and a class which implements this interface: My interface namespace BLL.Interfaces { interface IUser { List<User> GetAllUsers(); } } In my class namespace BLL.Services { public

How to inject dependencies using Ninject In ASP.NET WebForm?

痞子三分冷 提交于 2019-12-01 07:13:56
问题 I have a fair idea of using the Repository Pattern and have been attempting to "upgrade" our current way of creating ASP .Net websites. So i do the following Create a solution with a class project called DataAccessLayer and another class project called BusinessLogicLayer . Finally a 3rd project which is my ASP .Net website (a normal site). I add a dbml file to the DAL and drag a table, then in my BLL i add an interface and a class which implements this interface: My interface namespace BLL

MVC3 EF Unit of Work + Generic Repository + Ninject

陌路散爱 提交于 2019-12-01 06:12:32
I'm new to MVC3 and have been following the awesome tutorials on the asp.net website. However, I can't quite wrap my head around how to use Unit of Work and Generic Repository patterns with Ninject. I used this tutorial as a starting point: 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 Without using interfaces, I know I can implement it like so: Generic Repository: public class GenericRepository<TEntity> : IGenericRepository<TEntity> where TEntity : class { internal MyContext context;

MVC3 EF Unit of Work + Generic Repository + Ninject

女生的网名这么多〃 提交于 2019-12-01 05:30:51
问题 I'm new to MVC3 and have been following the awesome tutorials on the asp.net website. However, I can't quite wrap my head around how to use Unit of Work and Generic Repository patterns with Ninject. I used this tutorial as a starting point: 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 Without using interfaces, I know I can implement it like so: Generic Repository: public class

Multiple generic repositories in unitofwork?

人盡茶涼 提交于 2019-12-01 00:47:59
Lets say I have 2 tables. ProductCategory and Product . I have 1 generic repository that can handle both tables: public class GenericRepository<T> : IRepository<T> But when using unit of work pattern, am I forced to create a repository for ALL tables in my database? public interface IUnitOfWork : IDisposable { int SaveChanges(); IRepository<ProductCategory> ProductCategoryRepository { get; } IRepository<Product> ProductRepository { get; } } Is there not a way I can add the generic repository to the unit of work class? You can add a generic method to the IUnitOfWork interface: public interface

Should write complex query in Repository or Service layer?

ε祈祈猫儿з 提交于 2019-11-30 20:51:05
I are planning migrate our data access layer to using repository pattern and unit of work. I do know repository will help me to change persistence store (database, collection...etc) and technology such as EF to MongoDB easily. So I noticed some key points of implementation of a repository such as: Return IEnumerable instead of IQueryable Repository should take responsibilities for CRUD operations only Return type of repository method should be model (entity) Only implement repository for aggregate root If I apply these key points during implement repository in my project, I totally lost how to

How to join Multiple tables using Repository Pattern & Entity Framework?

只谈情不闲聊 提交于 2019-11-30 15:07:46
问题 I need to join multiple tables using repository pattern & Entity Framework (using C#). Is this possible? If so, please let me know how to do the same. 回答1: In EF, joining tables is done through the use of Navigation Properties. Basically, EF does it for you. When implementing in your Repositories, may it be Generic or not, you can call the Include method when building your query expression to tell EF to populate the navigation properties for you. Let's say we have these POCO class: public

Confusion between DTOs (linq2sql) and Class objects!

泄露秘密 提交于 2019-11-30 14:10:42
i have been successfully working with linq2sql and the linq DTOs (the classes that are created by linq2sql) .... I am confused, i have the task of updating an old application and i can see that my DTOs will be used how they should be .... to transport date I am using the repository pattern so i am passing data from the repository to the service via the linq2sql dtos... once i am in the service layer (this is basically my business logic) then I need to pass around class objects .. these class objects are basicaly a mirror image (more or less) of the dtos - there are some changes in some place

Best practices of implementing unit of work and repository pattern using ServiceStack.ORMLite

China☆狼群 提交于 2019-11-30 12:18:48
Supposing that there are two repository interface : interface IFooRepository { void Delete(int id); } interface IBarRepository { void Delete(int id); } And an IUnitOfWork interface like : interface IUnitOfWork : IDisposable { void Commit(); void Rollback(); } what is the best practices of implementing those interface using ServiceStack.ORMLite so that user can use them like MyFooRepository.Delete(4); // if an Exception throws here, Bar won't be deleted MyBarRepository.Delete(7); Or using (var uow = CreateUnitOfWork()) { MyFooRepository.Delete(4); MyBarRepository.Delete(7); uow.Commit(); //now

EF and repository pattern - ending up with multiple DbContexts in one controller - any issues (performance, data integrity)?

我是研究僧i 提交于 2019-11-30 11:39:17
问题 Most of my knowledge of ASP.NET MVC 3 comes from reading through the book Pro ASP.NET MVC 3 Framework by Adam Freeman and Steven Senderson. For my test application I have tried to stick to their examples very closely. I am using the repository pattern plus Ninject and Moq which means that unit testing work quite well (i.e. without needing to pull data from the database). In the book repositories are used like this: public class EFDbTestChildRepository { private EFDbContext context = new