What prompted you to change it to entities instead of values?
It can really simplify further developement (e.g. adding a new property to an entity). Now you can pass the entire entity as when you update the entity (e.g. add or remove new properties) you do not have to update all your method calls. And methods with long parameter chains (e.g. OrderManager.InsertOrder method had about 50 parameters) are bad.
Architecture improvements: ... 7. Repository pattern 8. Entities should be persistence ignorant. They should not depend on managers/services (remove custom properties).
Performance optimization: ... 5. Use lucene.net for search (Thanks, Will)
As for repository pattern. Should we create a generic repository (in this case we'll be using IRepository<Product> or IRepository<Category>)? Or should we create a repository for each service (in this case we'll be using IProductRepository or ICategoryRepository? What do you think?
BTW, if somebody is interested a generic repositry implementation is below
namespace NopSolutions.NopCommerce.BusinessLogic.Data { /// <summary> /// Repository /// </summary> publicpartialinterface IRepository<T> where T : BaseEntity { T GetById(object id); void Insert(T entity); void Update(T entity); void Delete(T entity);
IQueryable<T> Table { get; } }
/// <summary> /// Repository /// </summary> publicpartialclass EFRepository<T> : IRepository<T> where T : BaseEntity { #region Fields
publicvirtual T GetById(object id) { if (id == null) returnnull; EntityKey key = this._entities.BuildEntityKey(id); object result = null; if (this._context.TryGetObjectByKey(key, out result)) return (T)result; else returnnull; }
publicvirtualvoid Insert(T entity) { if (entity == null) thrownew ArgumentNullException("entity");
As for repository pattern. Should we create a generic repository (in this case we'll be using IRepository<Product> or IRepository<Category>)? Or should we create a repository for each service (in this case we'll be using IProductRepository or ICategoryRepository? What do you think
Maybe take a look at the Castle Project's implementation of ActiveRecord. This looks very similar. Hate for you to reinvent the wheel. Behind active record is just NHibernate, so what you're doing seems similar with EF behind it.
As for repository pattern. Should we create a generic repository (in this case we'll be using IRepository<Product> or IRepository<Category>)? Or should we create a repository for each service (in this case we'll be using IProductRepository or ICategoryRepository? What do you think?
Are there any advantages or disadvantages to using one or the other?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.