Redigeeri

Jagamisviis:


DataServiceCollection<T> Constructors

Definition

Creates a new instance of the DataServiceCollection<T> class.

Overloads

DataServiceCollection<T>()

Creates a new instance of the DataServiceCollection<T> class.

DataServiceCollection<T>(IEnumerable<T>)

Creates a new instance of the DataServiceCollection<T> class based on query execution.

DataServiceCollection<T>(DataServiceContext)

Creates a new instance of the DataServiceCollection<T> class that uses the specified DataServiceContext.

DataServiceCollection<T>(IEnumerable<T>, TrackingMode)

Creates 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>)

Creates 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>)

Creates a new instance of the DataServiceCollection<T> class a based on query execution and with the supplied change method delegates.

DataServiceCollection<T>(DataServiceContext, IEnumerable<T>, TrackingMode, String, Func<EntityChangedParams,Boolean>, Func<EntityCollectionChangedParams, Boolean>)

Creates a new instance of the DataServiceCollection<T> class a based on query execution, with the supplied change method delegates, and that uses the supplied DataServiceContext.

DataServiceCollection<T>()

Creates a new instance of the DataServiceCollection<T> class.

public:
 DataServiceCollection();
public DataServiceCollection ();
Public Sub New ()

Remarks

By default, automatic change tracking is enabled for a DataServiceCollection<T>. You can create an instance of DataServiceCollection<T> that uses manual change tracking when you create an instance using a constructor that enables you to supply a value of None for TrackingMode. When you use manual tracking, you must implement INotifyPropertyChanged and INotifyCollectionChanged and handle the raise events to manually report changes to the DataServiceContext.

Automatic change tracking begins after items are loaded into the collection.

Applies to

DataServiceCollection<T>(IEnumerable<T>)

Creates a new instance of the DataServiceCollection<T> class based on query execution.

public:
 DataServiceCollection(System::Collections::Generic::IEnumerable<T> ^ items);
public DataServiceCollection (System.Collections.Generic.IEnumerable<T> items);
new System.Data.Services.Client.DataServiceCollection<'T> : seq<'T> -> System.Data.Services.Client.DataServiceCollection<'T>
Public Sub New (items As IEnumerable(Of T))

Parameters

items
IEnumerable<T>

A DataServiceQuery<TElement> or LINQ query that returns an IEnumerable<T> collection of objects that are used to initialize the collection.

Remarks

The IEnumerable<T> collection of objects supplied for items is usually a query that returns the items in the collection. However, any IEnumerable<T> collection of the correct type can be supplied.

By default, automatic change tracking is enabled for a DataServiceCollection<T>. You can create an instance of DataServiceCollection<T> that uses manual change tracking when you create an instance using a constructor that enables you to supply a value of None for TrackingMode. When you use manual tracking, you must implement INotifyPropertyChanged and INotifyCollectionChanged and handle the raise events to manually report changes to the DataServiceContext.

Applies to

DataServiceCollection<T>(DataServiceContext)

Creates a new instance of the DataServiceCollection<T> class that uses the specified DataServiceContext.

public:
 DataServiceCollection(System::Data::Services::Client::DataServiceContext ^ context);
public DataServiceCollection (System.Data.Services.Client.DataServiceContext context);
new System.Data.Services.Client.DataServiceCollection<'T> : System.Data.Services.Client.DataServiceContext -> System.Data.Services.Client.DataServiceCollection<'T>
Public Sub New (context As DataServiceContext)

Parameters

context
DataServiceContext

The DataServiceContext used to track changes to objects in the collection.

Remarks

Use this constructor to create an empty DataServiceCollection<T> to which entity objects can be added without executing a query against the service or when an IEnumerable<T> is not available.

By default, automatic change tracking is enabled for a DataServiceCollection<T>. You can create an instance of DataServiceCollection<T> that uses manual change tracking when you create an instance using a constructor that enables you to supply a value of None for TrackingMode. When you use manual tracking, you must implement INotifyPropertyChanged and INotifyCollectionChanged and handle the raise events to manually report changes to the DataServiceContext.

Applies to

DataServiceCollection<T>(IEnumerable<T>, TrackingMode)

Creates a new instance of the DataServiceCollection<T> class based on query execution and with the specified tracking mode.

public:
 DataServiceCollection(System::Collections::Generic::IEnumerable<T> ^ items, System::Data::Services::Client::TrackingMode trackingMode);
public DataServiceCollection (System.Collections.Generic.IEnumerable<T> items, System.Data.Services.Client.TrackingMode trackingMode);
new System.Data.Services.Client.DataServiceCollection<'T> : seq<'T> * System.Data.Services.Client.TrackingMode -> System.Data.Services.Client.DataServiceCollection<'T>
Public Sub New (items As IEnumerable(Of T), trackingMode As TrackingMode)

Parameters

items
IEnumerable<T>

A DataServiceQuery<TElement> or LINQ query that returns an IEnumerable<T> collection of objects that are used to initialize the collection.

trackingMode
TrackingMode

A TrackingMode value that indicated whether or not changes made to items in the collection are automatically tracked.

Remarks

By default, automatic change tracking is enabled for a DataServiceCollection<T>. Use this class constructor and supply a value of None for trackingMode to create an instance of DataServiceCollection<T> that uses manual change tracking. When you use manual tracking, you must implement INotifyPropertyChanged and INotifyCollectionChanged and handle the raise events to manually report changes to the DataServiceContext.

The IEnumerable<T> collection of objects supplied for items is usually a query that returns the items in the collection. However, any IEnumerable<T> collection of the correct type can be supplied.

Applies to

DataServiceCollection<T>(DataServiceContext, String, Func<EntityChangedParams,Boolean>, Func<EntityCollectionChangedParams,Boolean>)

Creates a new instance of the DataServiceCollection<T> class with the supplied change method delegates and that uses the specified DataServiceContext.

public:
 DataServiceCollection(System::Data::Services::Client::DataServiceContext ^ context, System::String ^ entitySetName, Func<System::Data::Services::Client::EntityChangedParams ^, bool> ^ entityChangedCallback, Func<System::Data::Services::Client::EntityCollectionChangedParams ^, bool> ^ collectionChangedCallback);
public DataServiceCollection (System.Data.Services.Client.DataServiceContext context, string entitySetName, Func<System.Data.Services.Client.EntityChangedParams,bool> entityChangedCallback, Func<System.Data.Services.Client.EntityCollectionChangedParams,bool> collectionChangedCallback);
new System.Data.Services.Client.DataServiceCollection<'T> : System.Data.Services.Client.DataServiceContext * string * Func<System.Data.Services.Client.EntityChangedParams, bool> * Func<System.Data.Services.Client.EntityCollectionChangedParams, bool> -> System.Data.Services.Client.DataServiceCollection<'T>
Public Sub New (context As DataServiceContext, entitySetName As String, entityChangedCallback As Func(Of EntityChangedParams, Boolean), collectionChangedCallback As Func(Of EntityCollectionChangedParams, Boolean))

Parameters

context
DataServiceContext

The DataServiceContext used to track items in the collection.

entitySetName
String

The entity set of the objects in the collection.

entityChangedCallback
Func<EntityChangedParams,Boolean>

A delegate that encapsulates a method that is called when an entity changes.

collectionChangedCallback
Func<EntityCollectionChangedParams,Boolean>

A delegate that encapsulates a method that is called when the collection of entities changes.

Remarks

Use this constructor to create an empty DataServiceCollection<T> to which entity objects can be added without executing a query against the service or when an IEnumerable<T> is not available.

By default, automatic change tracking is enabled for a DataServiceCollection<T>. You can create an instance of DataServiceCollection<T> that uses manual change tracking when you create an instance using a constructor that enables you to supply a value of None for TrackingMode. When you use manual tracking, you must implement INotifyPropertyChanged and INotifyCollectionChanged and handle the raise events to manually report changes to the DataServiceContext.

Applies to

DataServiceCollection<T>(IEnumerable<T>, TrackingMode, String, Func<EntityChangedParams,Boolean>, Func<EntityCollectionChangedParams,Boolean>)

Creates a new instance of the DataServiceCollection<T> class a based on query execution and with the supplied change method delegates.

public:
 DataServiceCollection(System::Collections::Generic::IEnumerable<T> ^ items, System::Data::Services::Client::TrackingMode trackingMode, System::String ^ entitySetName, Func<System::Data::Services::Client::EntityChangedParams ^, bool> ^ entityChangedCallback, Func<System::Data::Services::Client::EntityCollectionChangedParams ^, bool> ^ collectionChangedCallback);
public DataServiceCollection (System.Collections.Generic.IEnumerable<T> items, System.Data.Services.Client.TrackingMode trackingMode, string entitySetName, Func<System.Data.Services.Client.EntityChangedParams,bool> entityChangedCallback, Func<System.Data.Services.Client.EntityCollectionChangedParams,bool> collectionChangedCallback);
new System.Data.Services.Client.DataServiceCollection<'T> : seq<'T> * System.Data.Services.Client.TrackingMode * string * Func<System.Data.Services.Client.EntityChangedParams, bool> * Func<System.Data.Services.Client.EntityCollectionChangedParams, bool> -> System.Data.Services.Client.DataServiceCollection<'T>
Public Sub New (items As IEnumerable(Of T), trackingMode As TrackingMode, entitySetName As String, entityChangedCallback As Func(Of EntityChangedParams, Boolean), collectionChangedCallback As Func(Of EntityCollectionChangedParams, Boolean))

Parameters

items
IEnumerable<T>

A DataServiceQuery<TElement> or LINQ query that returns an IEnumerable<T> collection of objects that are used to initialize the collection.

trackingMode
TrackingMode

A TrackingMode value that indicated whether or not changes made to items in the collection are automatically tracked.

entitySetName
String

The entity set of the objects in the collection.

entityChangedCallback
Func<EntityChangedParams,Boolean>

A delegate that encapsulates a method that is called when an entity changes.

collectionChangedCallback
Func<EntityCollectionChangedParams,Boolean>

A delegate that encapsulates a method that is called when the collection of entities changes.

Remarks

The entityChanged and collectionChanged functions are invoked by the PropertyChanged and CollectionChanged events, respectively. The entityChanged method takes an EntityCollectionChangedParams value and the collectionChanged method takes a EntityChangedParams value. Both methods must return a Boolean value that indicates whether the event was handled by the function. When the method returns true, the default behavior still occurs.

By default, automatic change tracking is enabled for a DataServiceCollection<T>. You can create an instance of DataServiceCollection<T> that uses manual change tracking when you create an instance using a constructor that enables you to supply a value of None for TrackingMode. When you use manual tracking, you must implement INotifyPropertyChanged and INotifyCollectionChanged and handle the raise events to manually report changes to the DataServiceContext.

Applies to

DataServiceCollection<T>(DataServiceContext, IEnumerable<T>, TrackingMode, String, Func<EntityChangedParams,Boolean>, Func<EntityCollectionChangedParams, Boolean>)

Creates a new instance of the DataServiceCollection<T> class a based on query execution, with the supplied change method delegates, and that uses the supplied DataServiceContext.

public:
 DataServiceCollection(System::Data::Services::Client::DataServiceContext ^ context, System::Collections::Generic::IEnumerable<T> ^ items, System::Data::Services::Client::TrackingMode trackingMode, System::String ^ entitySetName, Func<System::Data::Services::Client::EntityChangedParams ^, bool> ^ entityChangedCallback, Func<System::Data::Services::Client::EntityCollectionChangedParams ^, bool> ^ collectionChangedCallback);
public DataServiceCollection (System.Data.Services.Client.DataServiceContext context, System.Collections.Generic.IEnumerable<T> items, System.Data.Services.Client.TrackingMode trackingMode, string entitySetName, Func<System.Data.Services.Client.EntityChangedParams,bool> entityChangedCallback, Func<System.Data.Services.Client.EntityCollectionChangedParams,bool> collectionChangedCallback);
new System.Data.Services.Client.DataServiceCollection<'T> : System.Data.Services.Client.DataServiceContext * seq<'T> * System.Data.Services.Client.TrackingMode * string * Func<System.Data.Services.Client.EntityChangedParams, bool> * Func<System.Data.Services.Client.EntityCollectionChangedParams, bool> -> System.Data.Services.Client.DataServiceCollection<'T>
Public Sub New (context As DataServiceContext, items As IEnumerable(Of T), trackingMode As TrackingMode, entitySetName As String, entityChangedCallback As Func(Of EntityChangedParams, Boolean), collectionChangedCallback As Func(Of EntityCollectionChangedParams, Boolean))

Parameters

context
DataServiceContext

The DataServiceContext used to track items in the collection.

items
IEnumerable<T>

A DataServiceQuery<TElement> or LINQ query that returns an IEnumerable<T> collection of objects that are used to initialize the collection.

trackingMode
TrackingMode

A TrackingMode value that indicated whether or not changes made to items in the collection are automatically tracked.

entitySetName
String

The entity set of the objects in the collection.

entityChangedCallback
Func<EntityChangedParams,Boolean>

A delegate that encapsulates a method that is called when an entity changes.

collectionChangedCallback
Func<EntityCollectionChangedParams,Boolean>

A delegate that encapsulates a method that is called when the collection of entities changes.

Remarks

By default, automatic change tracking is enabled for a DataServiceCollection<T>. Use this class constructor to supply a value of None for trackingMode to create an instance of DataServiceCollection<T> that uses manual change tracking. When you use manual tracking, you must implement INotifyPropertyChanged and INotifyCollectionChanged and handle the raise events to manually report changes to the DataServiceContext.

The DataServiceContext must be supplied when items is not a DataServiceQuery<TElement> or QueryOperationResponse<T> that has a reference to a DataServiceContext instance.

The entityChanged and collectionChanged functions are invoked by the PropertyChanged and CollectionChanged events, respectively. The entityChanged method takes an EntityCollectionChangedParams value and the collectionChanged method takes a EntityChangedParams value. Both methods must return a Boolean value that indicates whether the event was handled by the function. When the method returns true, the default behavior will still occur.

Applies to