{"action":"created","issue":{"url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/10","labels_url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/10/comments","events_url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/10/events","html_url":"https://github.com/MarimerLLC/cslaforum/issues/10","id":90471226,"number":10,"title":"Generic interface in DAL layer for all BO.","user":{"login":"lmsantin","id":7717026,"avatar_url":"https://avatars.githubusercontent.com/u/7717026?v=3","gravatar_id":"","url":"https://api.github.com/users/lmsantin","html_url":"https://github.com/lmsantin","followers_url":"https://api.github.com/users/lmsantin/followers","following_url":"https://api.github.com/users/lmsantin/following{/other_user}","gists_url":"https://api.github.com/users/lmsantin/gists{/gist_id}","starred_url":"https://api.github.com/users/lmsantin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmsantin/subscriptions","organizations_url":"https://api.github.com/users/lmsantin/orgs","repos_url":"https://api.github.com/users/lmsantin/repos","events_url":"https://api.github.com/users/lmsantin/events{/privacy}","received_events_url":"https://api.github.com/users/lmsantin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-23T19:29:57Z","updated_at":"2015-06-23T20:35:22Z","closed_at":null,"body":"Has somebody tried to use a generic interface in DAL layer for all BO?\r\n\r\n\t/// <summary>\r\n\t/// Interface to be implemented by any business object.\r\n\t/// </summary>\r\n\t/// <typeparam name=\"D\">Dto object</typeparam>\r\n\t/// <typeparam name=\"I\">Info dto object</typeparam>\r\n\t/// <typeparam name=\"C\">List criteria</typeparam>\r\n\tpublic interface IBusinessObjectDal<D, I, C>\r\n\t{\r\n\t\tList<I> FetchList(C criteria);\r\n\t\tD Fetch(Guid id);\r\n\t\tvoid Insert(D dto);\r\n\t\tvoid Update(D dto);\r\n\t\tvoid Delete(Guid id);\r\n\t}\r\n"},"comment":{"url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/comments/114634234","html_url":"https://github.com/MarimerLLC/cslaforum/issues/10#issuecomment-114634234","issue_url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/10","id":114634234,"user":{"login":"lmsantin","id":7717026,"avatar_url":"https://avatars.githubusercontent.com/u/7717026?v=3","gravatar_id":"","url":"https://api.github.com/users/lmsantin","html_url":"https://github.com/lmsantin","followers_url":"https://api.github.com/users/lmsantin/followers","following_url":"https://api.github.com/users/lmsantin/following{/other_user}","gists_url":"https://api.github.com/users/lmsantin/gists{/gist_id}","starred_url":"https://api.github.com/users/lmsantin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmsantin/subscriptions","organizations_url":"https://api.github.com/users/lmsantin/orgs","repos_url":"https://api.github.com/users/lmsantin/repos","events_url":"https://api.github.com/users/lmsantin/events{/privacy}","received_events_url":"https://api.github.com/users/lmsantin/received_events","type":"User","site_admin":false},"created_at":"2015-06-23T20:35:22Z","updated_at":"2015-06-23T20:35:22Z","body":"Rocky we use to have an interface for each object, now I am thinking on having a generic one for all objects.\r\nI use to have this in the DAL for each BO:\r\n\r\n\t/// <summary>\r\n\t/// \r\n\t/// </summary>\r\n\tpublic interface ICategoryDal\r\n\t{\r\n\t\tList<CategoryInfoDto> FetchList();\r\n\t\tCategoryDto Fetch(Guid id);\r\n\t\tvoid Insert(CategoryDto dto);\r\n\t\tvoid Update(CategoryDto dto);\r\n\t\tvoid Delete(Guid id);\r\n\t}\r\n\r\nthen in dataportal:\r\n\r\n dalManager.GetProvider< GlobalPortal.Dal.Categories.ICategoryDal >()\r\n\r\nIf I use the generic interface then I don't need to define one interface for each BO and the change will be in the dataportal:\r\n\r\ndalManager.GetProvider< IBusinessObjectDal< CategoryDto, CategoryInfoDto, CategoryInfoCriteria >>(\"CategoryDal\")\r\n\r\nYou can see the GetProvider has a parameter to receive the DalEf class name because now I can not get it from the Interface type name using \" string.Format(TypeMask, typeof(T).Name.Substring(1)); \"\r\n\r\n"}}