repository-pattern

How to pass class instance to base class constructor

核能气质少年 提交于 2019-12-12 03:03:45
问题 I am having issues with my Transactions in that they are being escalated to a distributed transaction, which I don't want. From what I read, this is caused by opening multiple connections during the scope of the transaction. To correct this, I am re-working my code to be able to create one dbContext and pass it around to all the classes so I only have one context and hence one connection during the scope of the transaction. My question is, how do I create one instance of the context and pass

The relationship could not be changed because one or more of the foreign-key properties is non-nullable

自作多情 提交于 2019-12-12 02:39:38
问题 Exception : System.InvalidOperationException: 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 value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted. I have seen some solutions for the

Repository EF DBContext

牧云@^-^@ 提交于 2019-12-12 02:33:36
问题 my question is a two part issue. I am using the repository and unit of work pattern with entity framework. I have the following StockTransferRepository and StockTransfer is my aggregateRoot. Public Class StockTransferRepository Inherits WMSBaseRepository(Of StockTransfer, Int64, Dictionary(Of String, String)) Implements IStockTransferRepository Public Sub New(uow As IUnitOfWork) MyBase.New(uow) End Sub Public Overrides Function GetObjectSet() As IQueryable(Of StockTransfer) Return

Nhibernate queryover matching two IEnumerable

微笑、不失礼 提交于 2019-12-12 02:19:12
问题 i have this domain objects: public class Societa : EquatableObject<Societa> { public virtual int IdSocieta { get; set; } public virtual string NomeSocieta { get; set; } } public class Attivita { public virtual int IdAttivita { get; set; } public virtual IEnumerable<ProcessoEsaminato> Processi } public class ProcessoEsaminato { public virtual ProcessoSocieta ProcessoCoperto { get; set; } public virtual int Anno { get; set; } } public class ProcessoSocieta { public override int Id { get; set; }

Is it considered a bad practice for domain code to request data it needs?

房东的猫 提交于 2019-12-12 01:34:42
问题 Domain entities shouldn't contain code related to persistence, thus they should be Persistence Ignorant PI Data that the domain model DM is interested in can be delivered to DM either through domain entities 's navigation properties or by upper layers ( ie UI layer or service layer ). But I also assumed that in scenarios where particular domain entity must dynamically decide what data it requires, it is perfectly acceptable for that entity to request that data via component such as Repository

Multiple string connections in EF DbContext

 ̄綄美尐妖づ 提交于 2019-12-12 01:33:13
问题 I’m developing a MVC Website based in codeplex EFMVC solution, and I’m using Entity Framework and Repository, Unit of Work and Command Patterns. My website needs to be a SaaS solution (software as a service) multiple database. In my legacy Asp.Net WebForms I have a XML file that holds all the different string connections and I’m trying to use the same strategy. So in my LoginController I create a command that has company (to identify in which database will be connected) username and password.

repository pattern help

烂漫一生 提交于 2019-12-11 23:29:30
问题 I am trying to create a repository class for each table. For example I have TableA, TableB and TableC. TableB and TableC has Foreign key to TableA. I created an interface for TableA, TableB and TableC with SaveData() and ListData(). I have MVC form which inserts the data into these tables. When implementing these interface methods do I have to create a seperate class for each interface? Please let me if I am doing right. I appreciate any help. Public interface ITableA { void SaveData

DbRepository implementation without constructor in child classes

你。 提交于 2019-12-11 21:02:39
问题 I got the following objects: public class DbRepository<T> implements DbRepositoryInterface<T>{ protected T model; protected DbRepository(T model) { System.out.println("DbRepository created."); this.model = model; } @Override public T getModel() { return model; } } public interface DbRepositoryInterface<T> { public T getModel(); } public class PlayerDbRepository extends DbRepository<Player> { } In my code, where I want to make use of the PlayerDbRepository I would like to call:

Entity Framework: Many to Many Relationship

人盡茶涼 提交于 2019-12-11 17:44:38
问题 I have two tables with a Many-To-Many relationship like this: User( emailaddress , Name) UserAlerts( emailaddress , AlertId ) Alert( AlertId ,Title) Alerts have already been added to the database. When inserting a new user, I am doing a lookup on the AlertRepository . The problem is, Instead of creating a record in the User and the UsertAlerts tables only, its also adding an extra Alert record. I am using the following code: public ActionResult Register(UserModel model, int[] Alerts) User

Elasticsearch 5.x Repository Java Spring Boot

孤人 提交于 2019-12-11 15:26:05
问题 I want to use the elasticsearchrepository with Java Spring Boot: https://github.com/spring-projects/spring-data-elasticsearch It is not a RELEASE version, but should work for elasticsearch 5.4.0. I'm using ELK stack 5.x. I have the following pom.xml dependencies: <repositories> <repository> <id>elasticsearch-releases</id> <url>https://artifacts.elastic.co/maven</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <dependency>