DataServiceCollection(T) Class
Represents a dynamic entity collection that provides notifications when items get added, removed, or when the list is refreshed.
System.Collections.ObjectModel.Collection(T)
System.Collections.ObjectModel.ObservableCollection(T)
System.Data.Services.Client.DataServiceCollection(T)
Namespace: System.Data.Services.Client
Assembly: Microsoft.Data.Services.Client (in Microsoft.Data.Services.Client.dll)
The DataServiceCollection(T) type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | DataServiceCollection(T)() | Initializes a new instance of the DataServiceCollection(T) class. |
![]() | DataServiceCollection(T)(IEnumerable(T)) | Initializes a new instance of the DataServiceCollection(T) class based on query execution. |
![]() | DataServiceCollection(T)(DataServiceContext) | Initializes a new instance of the DataServiceCollection(T) class that uses the specified DataServiceContext. |
![]() | DataServiceCollection(T)(IEnumerable(T), TrackingMode) | Initializes a new instance of the DataServiceCollection(T) class based on query execution and with the specified tracking mode. |
![]() | DataServiceCollection(T)(DataServiceContext, String, Func(EntityChangedParams, Boolean), Func(EntityCollectionChangedParams, Boolean)) | Initializes a new instance of the DataServiceCollection(T) class with the supplied change method delegates and that uses the specified DataServiceContext. |
![]() | DataServiceCollection(T)(IEnumerable(T), TrackingMode, String, Func(EntityChangedParams, Boolean), Func(EntityCollectionChangedParams, Boolean)) | Initializes a new instance of the DataServiceCollection(T) class based on query execution and with the supplied change method delegates. |
![]() | DataServiceCollection(T)(DataServiceContext, IEnumerable(T), TrackingMode, String, Func(EntityChangedParams, Boolean), Func(EntityCollectionChangedParams, Boolean)) | Initializes a new instance of the DataServiceCollection(T) class based on query execution, with the supplied change method delegates, and that uses the supplied DataServiceContext. |
| Name | Description | |
|---|---|---|
![]() | Continuation | Gets a continuation object that is used to return the next set of paged results. |
![]() | Count | (Inherited from Collection(T).) |
![]() | Item | (Inherited from Collection(T).) |
![]() | Items | (Inherited from Collection(T).) |
| Name | Description | |
|---|---|---|
![]() | Add | (Inherited from Collection(T).) |
![]() | BlockReentrancy | (Inherited from ObservableCollection(T).) |
![]() | CancelAsyncLoad | |
![]() | CheckReentrancy | (Inherited from ObservableCollection(T).) |
![]() | Clear() | (Inherited from Collection(T).) |
![]() | Clear(Boolean) | Indicates whether all the items from the collection are removed. |
![]() | ClearItems | (Inherited from ObservableCollection(T).) |
![]() | Contains | (Inherited from Collection(T).) |
![]() | CopyTo | (Inherited from Collection(T).) |
![]() | Detach | Disables the DataServiceContext tracking of all items in the collection. |
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | (Inherited from Object.) |
![]() | GetEnumerator | (Inherited from Collection(T).) |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | IndexOf | (Inherited from Collection(T).) |
![]() | Insert | (Inherited from Collection(T).) |
![]() | InsertItem | Adds a specified item to the collection at the specified index. (Overrides ObservableCollection(T).InsertItem(Int32, T).) |
![]() | Load(IEnumerable(T)) | Loads a collection of entity objects into the collection.Not supported by the WCF Data Services 5.0 client for Silverlight. |
![]() | Load(T) | Loads a single entity object into the collection.Not supported by the WCF Data Services 5.0 client for Silverlight. |
![]() | LoadAsync() | Asynchronously loads items into the collection, when it represents the navigation property of an entity.Supported only by the WCF Data Services 5.0 client for Silverlight. |
![]() | LoadAsync(IQueryable(T)) | Asynchronously loads the collection by executing a DataServiceQuery(TElement).Supported only by the WCF Data Services 5.0 client for Silverlight. |
![]() | LoadAsync(Uri) | |
![]() | LoadNextPartialSetAsync | Loads the next page of data into the collection.Supported only by the WCF Data Services 5.0 client for Silverlight. |
![]() | MemberwiseClone | (Inherited from Object.) |
![]() | Move | (Inherited from ObservableCollection(T).) |
![]() | MoveItem | (Inherited from ObservableCollection(T).) |
![]() | OnCollectionChanged | (Inherited from ObservableCollection(T).) |
![]() | OnPropertyChanged | (Inherited from ObservableCollection(T).) |
![]() | Remove | (Inherited from Collection(T).) |
![]() | RemoveAt | (Inherited from Collection(T).) |
![]() | RemoveItem | (Inherited from ObservableCollection(T).) |
![]() | SetItem | (Inherited from ObservableCollection(T).) |
![]() | ToString | (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() | CollectionChanged | (Inherited from ObservableCollection(T).) |
![]() | LoadCompleted | Occurs when an asynchronous load operation completes.Supported only by the WCF Data Services 5.0 client for Silverlight. |
![]() | PropertyChanged | (Inherited from ObservableCollection(T).) |
| Name | Description | |
|---|---|---|
![]() ![]() | IList.Add | (Inherited from Collection(T).) |
![]() ![]() | IList.Contains | (Inherited from Collection(T).) |
![]() ![]() | ICollection.CopyTo | (Inherited from Collection(T).) |
![]() ![]() | IEnumerable.GetEnumerator | (Inherited from Collection(T).) |
![]() ![]() | IList.IndexOf | (Inherited from Collection(T).) |
![]() ![]() | IList.Insert | (Inherited from Collection(T).) |
![]() ![]() | IList.IsFixedSize | (Inherited from Collection(T).) |
![]() ![]() | ICollection(T).IsReadOnly | (Inherited from Collection(T).) |
![]() ![]() | IList.IsReadOnly | (Inherited from Collection(T).) |
![]() ![]() | ICollection.IsSynchronized | (Inherited from Collection(T).) |
![]() ![]() | IList.Item | (Inherited from Collection(T).) |
![]() ![]() | INotifyPropertyChanged.PropertyChanged | (Inherited from ObservableCollection(T).) |
![]() ![]() | IList.Remove | (Inherited from Collection(T).) |
![]() ![]() | ICollection.SyncRoot | (Inherited from Collection(T).) |
WCF Data Services provides the DataServiceCollection(T) class to support binding data to controls in client applications. This class inherits from the ObservableCollection(T) class, which implements the INotifyCollectionChanged interface and is the primary data binding mechanism for Windows Presentation Foundation (WPF) and Silverlight-based applications.
You can load an ObservableCollection(T) binding collection by using any collection that implements the IEnumerable(T) interface. Items loaded into the binding collection must implement the INotifyPropertyChanged interface. For more information, see Binding Data to Controls (WCF Data Services).
The following example is from the code-behind page for an Extensible Application Markup Language (XAML) page that defines the SalesOrders window in WPF. When the window is loaded, an DataServiceCollection(T) is created based on the result of a query that returns customers with related objects, filtered by country. This result is bound to the DataContext property of the StackPanel that is the root layout control for the WPF window.
The following is the XAML that defines the SalesOrders window in WPF for the previous example.
<Window x:Class="CustomerOrdersWpf"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Height="423" Width="679" Loaded="Window_Loaded">
<StackPanel Orientation="Vertical" Height="Auto" Name="LayoutRoot" Width="Auto">
<Label Content="Customer ID" Margin="20,0,0,0" />
<ComboBox Name="customerIDComboBox" DisplayMemberPath="CustomerID" ItemsSource="{Binding}"
IsSynchronizedWithCurrentItem="True" SelectedIndex="0" Height="23" Width="120"
HorizontalAlignment="Left" Margin="20,0,0,0" VerticalAlignment="Center" />
<ListView ItemsSource="{Binding Path=Orders}" Name="ordersDataGrid" Margin="34,46,34,50">
<ListView.View>
<GridView AllowsColumnReorder="False" ColumnHeaderToolTip="Line Items">
<GridViewColumn DisplayMemberBinding="{Binding Path=OrderID, Mode=OneWay}"
Header="Order ID" Width="50"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=OrderDate, Mode=TwoWay}"
Header="Order Date" Width="50"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Freight, Mode=TwoWay}"
Header="Freight Cost" Width="50"/>
</GridView>
</ListView.View>
</ListView>
<Button Name="saveChangesButton" Content="Save Changes" Click="saveChangesButton_Click"
Width="80" Height="30" Margin="450,0,0,0"/>
</StackPanel>
</Window>



