repository-pattern

Repository pattern for database that allows CRUD operations through Interops

旧巷老猫 提交于 2019-12-25 09:48:59
问题 The situation we are facing currently is Model Entities and database logic are tightly interweaved together which is making unit tests impossible. So, I decided to go with designing a Repository pattern. The basic structure of storage model what we see through Com interactions Root-Children[each child is another Root]. It's a tree structure. Understanding this, the Repository we designed is RootRepository for CRUD operations on root and ChildRepository internal to RootRepository for CRUD

Entity Framework 6 - Multiple DefaultConnectionFactory?

前提是你 提交于 2019-12-25 07:39:24
问题 I created 2 Contexts. SQLCE context and MYSQL contexts. public class SistemaContext : Sistema.Common.Repository.DataContext { static SistemaContext() { DbConfiguration.SetConfiguration(new DbConfigurationBase(Sistema.DataAccess.ConnectionStringFactory.DBType.MYSQL)); Database.SetInitializer(new MigrateDatabaseToLatestVersion<SistemaContext, Sistema.DataAccess.Migrations.Configuration>()); } public SistemaContext() : base(GetConnectionString()) { } private static string GetConnectionString() {

Is this a right pattern for Hibernate session/transaction management?

怎甘沉沦 提交于 2019-12-25 05:06:34
问题 we're developing an application using JSF 2.0 (primefaces) and Hibernate 3.6.1 We're following the approch of letting the higher level of the application be agnostic about the DAL framework.... that means that we don't use the session-per-request approach, but we configured Hibernate to handle the sessione on a per-thread basis. We've implemented a class whose role is to handle an "atomic operation", taking care of open the session and the transaction when they don't exixt already, and to

Generic Unit of Work and Repository pattern does not load related entities

风流意气都作罢 提交于 2019-12-25 02:55:53
问题 I actually had a previous post regarding the topic that I first thought was an EF issue. I then realized that EF has a lazy loading configuration built in and it appears that the Generic Unit of Work and Repository Pattern framework is not loading related entities automatically. When I use the .Include() extension in the DBSet<> property, the relationships begin populating without issue. This works: var list = (new DBContext()).Teams.Include(a => a.Creator).AsQueryable().ToList(); Using the

Repository pattern - Switch out the database and switch in XML files

爷,独闯天下 提交于 2019-12-24 19:09:38
问题 Repository pattern - Switch out the database and switch in XML files. Hello I have an asp.net MVC 2.0 project and I have followed the Repository pattern. Periodically, I am losing access to the database server so I want to have another mechanism in place (XML files) to continue developing. It is not possible to have a local version of the db unfortunately! I thought this would be relatively easy using the Repository pattern, to switch out the db repositories and switch in XML versions.

DDD: Confusion about repository/domain boundaries

扶醉桌前 提交于 2019-12-24 17:20:08
问题 My domain consists of Products, Departments, Classes, Manufacturers, DailySales, HourlySales. I have a ProductRepository which facilitates storing/retrieving products from storage. I have a DepartmentAndClass repository which facilitates storing/retrieving of departments and classes, as well as adding and removing products from those departments and classes. I also have a DailySales repository which I use to retrieve statistics about daily sales from multiple groupings. ie.. DailySales

How to update record using Entity Framework 7?

岁酱吖の 提交于 2019-12-24 16:15:08
问题 I am trying to update a field with various related tables using the EntityState.Modified but SaveChanges() is not applying the changes. I am using postman to post to the localhost/8000/api/co/1 and the status says 202 accepted. My repository is returning the record but it is not modified at all. Question What am I missing in my repository for the changes to take in affect? Do I need to set each property individually? (I have hundreds) Most the examples I can find related to the repository

Should the connectionstring come from the mvc project or the data project?

荒凉一梦 提交于 2019-12-24 12:16:31
问题 When using a separate project to handle db operations in an mvc project, should I store the connectionstring in the dbproject (using app.config) or should I keep the connectionstring in the web.config of the mvc project, and inject it into the repository (provided by the dbproject) when instantiating it? 回答1: The config is always read from the outermost app. The web.config is where your connectionstring should be. You can read it from your db project just as if it were the main project. You

How to Switch Dynamically between XML and SQL Repository in Web Service/ Web API?

喜欢而已 提交于 2019-12-24 10:38:18
问题 I have Web Service to carry CRUD operation. I have IProductRepository interface implemented by XMLProductRepository and SQLProductRepository. Now i use the repository instance in my controller of the web service to invoke Get/Put/POST and Delete operations which are defined respectively in XMLRepository and SQLRepository. But i am getting little confused as how to change dynamically between these two repositories as i want to make my web service database agnostic public interface

How to Switch Dynamically between XML and SQL Repository in Web Service/ Web API?

穿精又带淫゛_ 提交于 2019-12-24 10:36:13
问题 I have Web Service to carry CRUD operation. I have IProductRepository interface implemented by XMLProductRepository and SQLProductRepository. Now i use the repository instance in my controller of the web service to invoke Get/Put/POST and Delete operations which are defined respectively in XMLRepository and SQLRepository. But i am getting little confused as how to change dynamically between these two repositories as i want to make my web service database agnostic public interface