Compartilhar via


ObservableHashSet<T> Class

Definition

A hash set that implements the interfaces required for Entity Framework to use notification based change tracking for a collection navigation property.

See Local views of tracked entities in EF Core for more information and examples.

public class ObservableHashSet<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.ISet<T>, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging
type ObservableHashSet<'T> = class
    interface ISet<'T>
    interface ICollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface IReadOnlyCollection<'T>
    interface INotifyCollectionChanged
    interface INotifyPropertyChanged
    interface INotifyPropertyChanging
Public Class ObservableHashSet(Of T)
Implements ICollection(Of T), IEnumerable(Of T), INotifyCollectionChanged, INotifyPropertyChanged, INotifyPropertyChanging, IReadOnlyCollection(Of T), ISet(Of T)

Type Parameters

T

The type of elements in the hash set.

Inheritance
ObservableHashSet<T>
Implements

Remarks

See Local views of tracked entities in EF Core for more information and examples.

Constructors

ObservableHashSet<T>()

Initializes a new instance of the ObservableHashSet<T> class that is empty and uses the default equality comparer for the set type.

ObservableHashSet<T>(IEnumerable<T>, IEqualityComparer<T>)

Initializes a new instance of the ObservableHashSet<T> class that uses the specified equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

ObservableHashSet<T>(IEnumerable<T>)

Initializes a new instance of the ObservableHashSet<T> class that uses the default equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

ObservableHashSet<T>(IEqualityComparer<T>)

Initializes a new instance of the ObservableHashSet<T> class that is empty and uses the specified equality comparer for the set type.

Properties

Comparer

Gets the IEqualityComparer<T> object that is used to determine equality for the values in the set.

Count

Gets the number of elements that are contained in the hash set.

IsReadOnly

Gets a value indicating whether the hash set is read-only.

Methods

Add(T)

Adds the specified element to the hash set.

Clear()

Removes all elements from the hash set.

Contains(T)

Determines whether the hash set object contains the specified element.

CopyTo(T[], Int32, Int32)

Copies the specified number of elements of the hash set to an array, starting at the specified array index.

CopyTo(T[], Int32)

Copies the elements of the hash set to an array, starting at the specified array index.

CopyTo(T[])

Copies the elements of the hash set to an array.

ExceptWith(IEnumerable<T>)

Removes all elements in the specified collection from the hash set.

GetEnumerator()

Returns an enumerator that iterates through the hash set.

IntersectWith(IEnumerable<T>)

Modifies the current hash set to contain only elements that are present in that object and in the specified collection.

IsProperSubsetOf(IEnumerable<T>)

Determines whether the hash set is a proper subset of the specified collection.

IsProperSupersetOf(IEnumerable<T>)

Determines whether the hash set is a proper superset of the specified collection.

IsSubsetOf(IEnumerable<T>)

Determines whether the hash set is a subset of the specified collection.

IsSupersetOf(IEnumerable<T>)

Determines whether the hash set is a superset of the specified collection.

OnCollectionChanged(NotifyCollectionChangedEventArgs)

Raises the CollectionChanged event.

OnPropertyChanged(PropertyChangedEventArgs)

Raises the PropertyChanged event.

OnPropertyChanging(PropertyChangingEventArgs)

Raises the PropertyChanging event.

Overlaps(IEnumerable<T>)

Determines whether the current hash set object and a specified collection share common elements.

Remove(T)

Removes the specified element from the hash set.

RemoveWhere(Predicate<T>)

Removes all elements that match the conditions defined by the specified predicate from the hash set.

SetEquals(IEnumerable<T>)

Determines whether the hash set and the specified collection contain the same elements.

SymmetricExceptWith(IEnumerable<T>)

Modifies the current hash set to contain only elements that are present either in that object or in the specified collection, but not both.

TrimExcess()

Sets the capacity of the hash set to the actual number of elements it contains, rounded up to a nearby, implementation-specific value.

UnionWith(IEnumerable<T>)

Modifies the hash set to contain all elements that are present in itself, the specified collection, or both.

Events

CollectionChanged

Occurs when the contents of the hash set changes.

PropertyChanged

Occurs when a property of this hash set (such as Count) changes.

PropertyChanging

Occurs when a property of this hash set (such as Count) is changing.

Explicit Interface Implementations

ICollection<T>.Add(T)
IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

IEnumerable<T>.GetEnumerator()

Returns an enumerator that iterates through the collection.

Applies to