DataServiceCollection<T> 建構函式 (IEnumerable<T>)
建立 DataServiceCollection<T> 類別的新執行個體,此執行個體基於查詢執行。
命名空間: System.Data.Services.Client
組件: Microsoft.Data.Services.Client (在 Microsoft.Data.Services.Client.dll 中)
語法
'宣告
Public Sub New ( _
items As IEnumerable(Of T) _
)
'用途
Dim items As IEnumerable(Of T)
Dim instance As New DataServiceCollection(items)
public DataServiceCollection(
IEnumerable<T> items
)
public:
DataServiceCollection(
IEnumerable<T>^ items
)
new :
items:IEnumerable<'T> -> DataServiceCollection
public function DataServiceCollection(
items : IEnumerable<T>
)
參數
- items
型別:System.Collections.Generic.IEnumerable<T>
DataServiceQuery<TElement> 或 LINQ 查詢,可傳回用來初始化集合之物件的 IEnumerable<T> 集合。
備註
提供給 items 的物件 IEnumerable<T> 集合通常是傳回集合中之項目的查詢。 但是,也可以提供正確型別的任何 IEnumerable<T> 集合。
根據預設,DataServiceCollection<T> 已啟用自動變更追蹤。 當您使用建構函式提供 None 值給 TrackingMode 來建立執行個體時,您可以建立使用手動變更追蹤的 DataServiceCollection<T> 執行個體。 當您使用手動追蹤時,您必須實作 INotifyPropertyChanged 和 INotifyCollectionChanged 並處理引發事件,向 DataServiceContext 手動回報變更。