我與Catel,MVVM,WPF的工作,我想知道如何與嵌套/ hiearchical的數據。hiearchical數據,catel和MVVM
讓我們從我有一個客戶列表,每個發票的列表,每個InvoiceItems列表數據庫說。客戶擁有許多擁有許多InvoiceItems的發票。
我有一個工作的解決方案,但我不喜歡它。我的方法是構建一個類似ado.net「數據集」的類的集合。一個類將代表這個hiearchy的每一層。
這個頂層類,CustomerModel,將包含的InvoiceBlocks的集合:
CustomerModel
的ObservableCollection的< InvoicesBlocks>
每個InvoceBlock將包含發票和InvoiceItems的集合:
InvoiceBlock
Invoice
ObservableCollection < InvoiceItems>
在涉及數據綁定路徑= satements之前,它似乎很聰明。有時候我不得不通過集合來更新總數,從而擊敗了MVVM的一個主要賣點。
所以,我決定了解更多有關LINQ查詢和數據綁定分組。這是專業人士的做法嗎?
我使用ADO.NET實體模型:使用(VAR =新DataEntity()),我應該試着爲創建一個服務,或者直接從調用它,說一個InvoiceService?謝謝。 –
明白了!我將ADO.NET實體模型DataEntities()放入它自己的服務中。甜。 –