1
我有以下的數據庫模型: 我使用LINQ到SQL和設計模式庫作爲描述休耕頁http://www.remondo.net/repository-pattern-example-csharp/查詢與存儲庫模式
這是一個類圖:
我想做出這樣的查詢,但是改爲使用資源庫設計模式
ExampleRepositoryDataSet data = new ExampleRepositoryDataSet();
var query = from hotel in data.Hotel
join category in data.Category on hotel.Category equals category.IdCategory
join country in data.Country on hotel.Contry equals country.IdContry
where country.Name == "Cuba"
orderby hotel.Rating descending
group new {hotel, category, country} by category.Name;
與單一實體接入場景打交道時,你正在使用的模式是好的。當你不得不在多個實體之間進行合成時,並非如此。沒有正確的答案,您應該提交您提交的查詢的位置,但處理這些類型問題的編排層將是一個好的開始。您仍然可以使用個人存儲庫訪問編排層內的所有酒店,類別和國家/地區數據。祝你好運。 – 2014-09-05 14:38:59
@RobEpstein謝謝你的幫助,然後你建議我添加數據源並使用ExampleRepositoryDataSet對象來查詢。我可以使用查詢對象模式? – Cyberguille 2014-09-05 15:16:49
你的問題是什麼? – 2014-09-05 15:51:32