unit-of-work

Unit of Work and EF

你离开我真会死。 提交于 2021-02-11 08:22:49
问题 I'm making an interface following the Unit of Work pattern. My interface looks like this: public interface IDataContext : IDisposable { void SaveChanges(); TSource Create<TSource>(TSource toCreate) where TSource : class; TSource Update<TSource>(TSource toUpdate) where TSource : class; bool Delete<TSource>(TSource toDelete) where TSource : class; IQueryable<TSource> Query<TSource>(); } So far so good. Now I implement it in my Data Layer, which uses EF4 as data provider. I came up with this

Unit of Work and EF

混江龙づ霸主 提交于 2021-02-11 08:22:15
问题 I'm making an interface following the Unit of Work pattern. My interface looks like this: public interface IDataContext : IDisposable { void SaveChanges(); TSource Create<TSource>(TSource toCreate) where TSource : class; TSource Update<TSource>(TSource toUpdate) where TSource : class; bool Delete<TSource>(TSource toDelete) where TSource : class; IQueryable<TSource> Query<TSource>(); } So far so good. Now I implement it in my Data Layer, which uses EF4 as data provider. I came up with this

Unit of Work and EF

淺唱寂寞╮ 提交于 2021-02-11 08:21:47
问题 I'm making an interface following the Unit of Work pattern. My interface looks like this: public interface IDataContext : IDisposable { void SaveChanges(); TSource Create<TSource>(TSource toCreate) where TSource : class; TSource Update<TSource>(TSource toUpdate) where TSource : class; bool Delete<TSource>(TSource toDelete) where TSource : class; IQueryable<TSource> Query<TSource>(); } So far so good. Now I implement it in my Data Layer, which uses EF4 as data provider. I came up with this

Nested Unit of Work in Entity Framework

自古美人都是妖i 提交于 2021-02-10 18:19:51
问题 I try to implement Unit of Work pattern in my application with use of nested units of work . I have the following interfaces: interface IDataService { IUnitOfWork NewUnitOfWork(); INestedUnitOfWork NewNestedUnitOfWork(IUnitOfWork parent); } interface IUnitOfWork : IDisposable { void Commit(); } interface INestedUnitOfWork : IUnitOfWork { IUnitOfWork Parent { get; } object GetParentObject(object obj); // get the same object in parent uow object GetNestedObject(object obj); // get the same

Generic Unit Of Work

六月ゝ 毕业季﹏ 提交于 2021-02-07 09:26:33
问题 I have implemented EntityFramework pattern along with Repository and Unit Of Work. The implementation is similar to Code Project Repository Example, however I need an enhancement for the Unit Of Work. The unit of work public class GenericUnitOfWork : IDisposable { // Initialization code public Dictionary<Type, object> repositories = new Dictionary<Type, object>(); public IRepository<T> Repository<T>() where T : class { if (repositories.Keys.Contains(typeof(T)) == true) { return repositories

Should Class Implement Both IAsyncDisposable and IDisposable?

妖精的绣舞 提交于 2020-08-08 06:38:07
问题 For example I have this class: public class UnitOfWork : IUnitOfWork { private readonly ApplicationDbContext _context; public IProductRepository Products { get; private set; } public ICategoryRepository Categories { get; private set; } public IPhotoRepository Photos { get; private set; } public UnitOfWork(ApplicationDbContext context, IProductRepository productRepository, ICategoryRepository categoryRepository, IPhotoRepository photoRepository) { _context = context; Products =

Dependency Injection and multiple projects in solution

拈花ヽ惹草 提交于 2020-01-24 23:27:19
问题 I have been following this article concerning the use of the repository pattern and UnitOfWork with entity framework. I am also planning to use Ninject as my IOC container for an upcoming project. Given the sample code from the article, the NorthwindContext class in the NorthwindData project implements the IUnitOfWork interface which live inside of the NorthwindModel project. How can I utilize dependency injection to eliminate the dependency on NorthwindModel to NorthwindData? The repository

Why the database data is not being updated but object did and without error?

﹥>﹥吖頭↗ 提交于 2020-01-23 06:52:00
问题 I have this bank ATM mock-up app which implements some Domain-Driven Design architecture and Unit of Work pattern. This app have 3 basic functions: Check balance Deposit Withdraw These are the project layers: ATM.Model (Domain model entity layer) namespace ATM.Model { public class BankAccount { public int Id { get; set; } public string AccountName { get; set; } public decimal Balance { get; set; } public decimal CheckBalance() { return Balance; } public void Deposit(int amount) { // Domain