Table of Contents

Method ToHashSet

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

ToHashSet<T>(IMappedQuery<T>, IEqualityComparer<T>?)

Reads every mapped row into a new HashSet<T>.

public static HashSet<T> ToHashSet<T>(this IMappedQuery<T> query, IEqualityComparer<T>? comparer = null)

Parameters

query IMappedQuery<T>

The query to execute.

comparer IEqualityComparer<T>

The comparer for the rows, or null to use the default comparer.

Returns

HashSet<T>

A set of the distinct rows. Rows that compare equal to an earlier row are dropped.

Type Parameters

T

The type each row is mapped to.

Remarks

All rows are buffered in memory before the call returns. Use Read(Action<IEnumerable<T>>) to process very large results as a stream.

See Also