{"action":"created","issue":{"url":"https://api.github.com/repos/philieu/EntityFramework.Repository/issues/1","labels_url":"https://api.github.com/repos/philieu/EntityFramework.Repository/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/philieu/EntityFramework.Repository/issues/1/comments","events_url":"https://api.github.com/repos/philieu/EntityFramework.Repository/issues/1/events","html_url":"https://github.com/philieu/EntityFramework.Repository/issues/1","id":108613616,"number":1,"title":"IRepository.cs Extensions ","user":{"login":"zyz","id":714535,"avatar_url":"https://avatars.githubusercontent.com/u/714535?v=3","gravatar_id":"","url":"https://api.github.com/users/zyz","html_url":"https://github.com/zyz","followers_url":"https://api.github.com/users/zyz/followers","following_url":"https://api.github.com/users/zyz/following{/other_user}","gists_url":"https://api.github.com/users/zyz/gists{/gist_id}","starred_url":"https://api.github.com/users/zyz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyz/subscriptions","organizations_url":"https://api.github.com/users/zyz/orgs","repos_url":"https://api.github.com/users/zyz/repos","events_url":"https://api.github.com/users/zyz/events{/privacy}","received_events_url":"https://api.github.com/users/zyz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-28T08:43:05Z","updated_at":"2015-09-28T08:51:10Z","closed_at":null,"body":"Hi,\r\nYour EntityFramework.Repository is very good,  \r\nbut the IRepository to provide more interface will be better. \r\nsuch as: Find(primary key), single table page, etc.\r\nI think in the framework using EntityFramework Extended will be better.\r\nTo provide a common interface IBaseService.cs and implementation classes BaseService.cs will be more perfect. \r\nFor example: \r\n\r\nIBaseService.cs\r\npublic interface IBaseService<TEntity>  where TEntity : class\r\n    {\r\n        void Delete(TEntity entity);\r\n        void Insert(TEntity entity);\r\n        void Update(TEntity entity);\r\n    }\r\nBaseService.cs\r\npublic class BaseService<TContext, TEntity> : IBaseService<TEntity>\r\n        where TEntity : class\r\n        where TContext : IDbContext\r\n    {\r\n        protected IUnitOfWork<TContext> _unitOfWork;\r\n        protected IRepository<TContext, TEntity> _entityRepository;\r\n\r\n        public BaseService(IUnitOfWork<TContext> unitOfWork, IRepository<TContext, TEntity> entityRepository)\r\n        {\r\n            this._unitOfWork = unitOfWork;\r\n            this._entityRepository = entityRepository;\r\n        }\r\n\r\n\r\n        public void Delete(TEntity entity)\r\n        {\r\n            _entityRepository.Delete(entity);\r\n            _unitOfWork.SaveChanges();\r\n        }\r\n\r\n        public void Insert(TEntity entity)\r\n        {\r\n            _entityRepository.Insert(entity);\r\n            _unitOfWork.SaveChanges();\r\n        }\r\n\r\n        public void Update(TEntity entity)\r\n        {\r\n            _entityRepository.Update(entity);\r\n            _unitOfWork.SaveChanges();\r\n        }\r\n}\r\nNext Database BaseService\r\npublic class RedisBaseService<TEntity> : BaseService<IRedis2Context, TEntity>\r\n        where TEntity : class\r\n    {\r\n        private static readonly ContextAdaptor<IRedis2Context> contextAdapter = new ContextAdaptor<IRedis2Context>(new Redis2Context());\r\n\r\n        public RedisBaseService() : base(new UnitOfWork<IRedis2Context>(contextAdapter), new Repository<IRedis2Context, TEntity>(contextAdapter))\r\n        {\r\n        }\r\n    }\r\nNext\r\nIUserService.cs\r\npublic interface IUserService : IBaseService<User>\r\n    {\r\n        void Add(User user);\r\n    }\r\nUserService.cs\r\npublic class UserService : RedisBaseService<User>, IUserService\r\n    {\r\n       //I don't know this problem?\r\n       //I think here the database context should be from base class RedisBaseService.cs inheritance \r\n       private IRepository<IRedis2Context, Role> _roleRepository;\r\n\r\n        public UserService(IRepository<IRedis2Context, Role> roleRepository)\r\n        {\r\n            this._roleRepository = roleRepository;\r\n        }\r\n        public void Add(User user)\r\n        {\r\n            _entityRepository.Insert(user);\r\n            _unitOfWork.SaveChanges();\r\n        }\r\n    }\r\nThe above example code just for the sake of multidatabase, single table the public interface of reuse"},"comment":{"url":"https://api.github.com/repos/philieu/EntityFramework.Repository/issues/comments/143682251","html_url":"https://github.com/philieu/EntityFramework.Repository/issues/1#issuecomment-143682251","issue_url":"https://api.github.com/repos/philieu/EntityFramework.Repository/issues/1","id":143682251,"user":{"login":"zyz","id":714535,"avatar_url":"https://avatars.githubusercontent.com/u/714535?v=3","gravatar_id":"","url":"https://api.github.com/users/zyz","html_url":"https://github.com/zyz","followers_url":"https://api.github.com/users/zyz/followers","following_url":"https://api.github.com/users/zyz/following{/other_user}","gists_url":"https://api.github.com/users/zyz/gists{/gist_id}","starred_url":"https://api.github.com/users/zyz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyz/subscriptions","organizations_url":"https://api.github.com/users/zyz/orgs","repos_url":"https://api.github.com/users/zyz/repos","events_url":"https://api.github.com/users/zyz/events{/privacy}","received_events_url":"https://api.github.com/users/zyz/received_events","type":"User","site_admin":false},"created_at":"2015-09-28T08:51:10Z","updated_at":"2015-09-28T08:51:10Z","body":"Looking forward to your update..."}}