0
是否有可能創建一個通用的CRUD存儲庫在VB.Net MySQL連接而不依賴於任何第三方ORM?.Net MySQL通用CRUD存儲庫
我的意思是,MySQL CRUD依賴於字符串來識別你想訪問哪個表和字段,同時我們有一個.Net對象。
實現此目的的唯一方法是使用ORM和/或Reflection類嗎?我們不能對對象或字符串做一些匹配嗎?
比方說,我得到了這個倉庫接口:
public interface IRepository<T> where T:class
{
void Insert(T entity);
void Delete(T entity);
IQueryable<T> GetAll();
T GetById(string id);
}
看到這個界面之後是什麼在我的腦海裏是創造我的每個對象的個人信息庫,即使CRUD方法是非常相似的。
例如,我必須爲Employee CRUD創建一個存儲庫。
class EmployeeRepository : IRepository<Employee>
{
private string _query;
public IQueryable<Employee> GetAll(Employee entity)
{
_query = "SELECT * FROM tbl_msemployee";
//Do query here, which will eventually return a list of Employee object
}
}
實體框架是否作爲第三方ORM計數? – 2013-02-17 14:02:44
@HighCore我不太確定,但在這個話題中,我必須說是的。 – 2013-02-17 15:15:29