[英]Automatic Data Access Layer
我從根本上討厭寫數據訪問層。 我認為這是無聊而毫無意義的努力。 我設想一個開發環境,在這里我可以創建我的實體/模型並開始構建應用程序。 編寫DAL,過程等所花費的時間只會使我對項目充滿熱情。
我想要的是用於數據的通用存儲庫接口。 就像是:
public interface IRepository
{
//Get individual TEntity item by id
TEntity GetItem<TIdentifier, TEntity>(TIdentifier id);
//Get individual TEntity item by the expression
TEntity GetItem<TIdentifier, TEntity, TArg>(Expression<Func<TArg, TEntity>> expression);
//Get individual TEntity item by the expression
TEntity GetItem<TIdentifier, TEntity, TArg1, TArg2>(Expression<Func<TArg1, TArg2, TEntity>> expression);
//Get all TEntity items
IList<TEntity> GetList<TEntity>();
//Get all TEntity items, filtered by the expression
IList<TEntity> GetList<TEntity, TArg>(Expression<Func<TArg, IList<TEntity>>> expression);
//Get all TEntity items, filtered by the expression
IList<TEntity> GetList<TEntity, TArg1, TArg2>(Expression<Func<TArg1, TArg2, IList<TEntity>>> expression);
TIdentifier CreateItem...
bool UpdateItem...
bool DeleteItem...
}
我對某些適合的東西特別感興趣
...但是該理論將適用於任何數據存儲庫
有沒有人遇到過現成的解決方案,或者我必須通過編寫比我想動搖的更多的數據訪問層來解決問題。
注意:我了解ORM,我想要一些東西來消除編寫任何DAL或存儲的proc的要求。
看看NHibernate,Castle ActiveRecord,SubSonic,LinqToSql等...
您說您了解ORM,但是它們至少在可能的范圍內完全滿足您的要求。
我知道您說過您了解ORM,但不希望使用它們,但是您可以處理使用LINQ
編寫的數據訪問方法嗎?
我發現我喜歡在SQL
語句上編寫LINQ
語句。 如果您願意這樣做,我將簽出Entity Framework,LINQ to SQL, NHibernate等。
編輯:如果要使用Azure,請查看以下鏈接: http : //social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/74a0a57e-d979-48ed-b534-f449bac0f90d
這是薩拉曼卡的目標之一。 雖然它仍處於早期階段,但是我們可以使用一兩手編碼。
如果需要現有解決方案,建議您深入研究可能與代碼生成工具關聯的ORM(如其他建議):
查看這個非常完整的ORM列表 。
LINQ to Entities和.Net的Entities框架是兩個最佳的跨服務器解決方案。
此處的更多信息: http : //msdn.microsoft.com/zh-cn/library/bb386964.aspx
使用LINQ,實際上可以為您完成所有數據訪問任務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.