unit-of-work

Help with EF Code first connection string

与世无争的帅哥 提交于 2020-01-03 03:38:10
问题 Im trying to implement a UnitofWork pattern using this Scott Allen tutorial My current SqlUnitOfWork is the folowing public class SqlUnitOfWork : IUnitOfWork { public SqlUnitOfWork() { var connectionString = ConfigurationManager .ConnectionStrings[ConnectionStringName] .ConnectionString; _context = new ObjectContext(connectionString); _context.ContextOptions.LazyLoadingEnabled = true; } public IRepository<PhysicalTest> PhysicalTests { get { if (_physicalTests == null) { _physicalTests = new

DDD (java) Aggregate roots and persistence

半世苍凉 提交于 2020-01-02 14:49:42
问题 I'm creating an application which will make use of tables of various sizes, while I have worked on a project labeled DDD before it didn't really get the persistence part right and thus I'm left researching things. One thing I don't fully grasp and can't seem to find concrete examples of is how to persist "children" of aggregate roots. I am working without an ORM (just plain old DAO) which is quite hard to find examples of (this is actually a project for uni which is db specific so I'm 'not

DDD (java) Aggregate roots and persistence

蓝咒 提交于 2020-01-02 14:48:10
问题 I'm creating an application which will make use of tables of various sizes, while I have worked on a project labeled DDD before it didn't really get the persistence part right and thus I'm left researching things. One thing I don't fully grasp and can't seem to find concrete examples of is how to persist "children" of aggregate roots. I am working without an ORM (just plain old DAO) which is quite hard to find examples of (this is actually a project for uni which is db specific so I'm 'not

How to get id from Add using UnitOfWork pattern?

梦想与她 提交于 2020-01-02 05:34:26
问题 I am using the UnitOfWork pattern to abstract database access in my Asp.Net application. Basically I follow the UnitOfWork pattern approach described here: https://chsakell.com/2015/02/15/asp-net-mvc-solution-architecture-best-practices/ However, I'm struggling to understand, how I will get the Id of a newly added item. Like if I want to add a new customer to my Customer repository, how will I get the customer id? The problem is that Add and Commit are decoupled, and the Id is not known until

taking advantage of inheritance in Controllers and Views

佐手、 提交于 2020-01-01 08:27:53
问题 I had posted this review on codereview.stackexchange.com a while ago... I feel it may be more suitable for stackoverflow, since it is more of a question than a code review. Its going to take a bit of explanation, please bear with me . I am developing an e-commerce website in ASP.NET MVC. Users can post advertisements of different types on the site. I am using inheritance to define my Ad types, and this question is about taking advantage of the hierarchical structure to remove repeated code in

Repository & Unit of Work Pattern for Entity Framework using Dependency Injection

寵の児 提交于 2019-12-31 04:14:10
问题 I tried the T4-Template from http://efrepository.codeplex.com, but I'm struggling with the DI (uses StructureMap) Example code. It's just not enough for a DI beginner like me. It doesn't even compile. I already have done a few sample projects with its Non-DI Template. And it worked out great. I love, that it generates all necessary repositories and that I can easily customize and extend them. But I can't get the DI Examples working. Are there any similar projects (with better docs)? 回答1: I

How to marry EntityFramework, Repository, UnitOfWork and Automapper altogether in one MVC application?

ε祈祈猫儿з 提交于 2019-12-30 07:01:10
问题 First I decided to create one Interface called it IDataAccessLayer and started putting everything into it: methods like GetUsers() , GetUser(int id) , GetOrderByNumber(int number) , DeleteOrder(int Id) etc. That worked just perfect at first. But then I realized that the concrete implementation of DataLayer:IDataLayer is growing to big. I decided to cut it into several partial class files. Still I was feeling that I'm doing something really wrong. Then I decided to create interfaces for each

A second operation started on this context before a previous asynchronous operation completed with UnitofWork and async

谁说我不能喝 提交于 2019-12-25 19:36:29
问题 A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe. My unitofwork code public class UnitOfWork : IUnitOfWork { private readonly CAMSDbEntities _context; private bool _disposed; public Dictionary<Type, object> repositories = new Dictionary<Type, object>(); private Guid _objectId

Warning: spl_object_hash() expects parameter 1 to be object

自古美人都是妖i 提交于 2019-12-25 17:19:07
问题 Warning: spl_object_hash() expects parameter 1 to be object, string given in /var/www/sitetwo/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 1367 I created MainBlogBundle with Category.php and Product.php using yml mapping annotation via php app/console commands. After using CRUD actions for add/edit/delete/show actions I tried to add a category and after submitting Add category form I get the Warning: spl_object_hash() expects parameter 1 to be object, string given in /var/www

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