Class Union
The entry point for composing a typed UNION/UNION ALL: each branch reads one entity type,
optionally filtered, projected into the common result shape — an anonymous type or a member-init
POCO whose members are entity members or constants (constants tag which branch a row came from).
Combine branches with All<TResult>(params UnionBranch<TResult>[]) (keep duplicates) or
Distinct<TResult>(params UnionBranch<TResult>[]) (SQL UNION semantics), and run the query on a unit of
work that implements IUnionQueryRunner.
public static class Union
- Inheritance
-
Union
- Inherited Members
Examples
var feed = UnionQuery.All(
Union.Of<Order>().Where(x => x.Status == "overdue")
.Select(x => new { Name = x.Customer, Origin = "order" }),
Union.Of<Buyer>()
.Select(x => new { x.Name, Origin = "buyer" }))
.OrderBy(row => row.Name)
.Take(20);
var rows = await unitOfWork.UnionAsync(feed);
Methods
Of<TEntity>()
Starts a union branch over TEntity.
public static UnionSource<TEntity> Of<TEntity>() where TEntity : class
Returns
- UnionSource<TEntity>
Type Parameters
TEntityThe entity type the branch reads.