/// <summary> /// Appends a table-valued parameter from the current values, e.g. <c>@TP0</c>, to the projection buffer. /// </summary> /// <param name="projection">The current projection.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute TvpName(this IProjection projection) { if (projection.Data == null) { throw new ProjectionException($"No value information found for {projection.Metadata.Identity}."); } else if (!projection.Any()) { throw new ProjectionException($"No attributes found for {projection.Metadata.Identity}."); } RelationHeader header = new RelationHeader(projection.Metadata.Identity.Schema, projection.Header.Select(a => a.Metadata.Relation).ToList()); Relation relation = new Relation(projection.Data.Input, header); string paramName = projection.Context.Lookup.Custom("TP", projection.Identity, metadata: projection.Metadata.Identity, value: projection.Data.Input); string dialectName = projection.Context.Domain.Dialect.Parameter(paramName); return(projection.Attr().Append(dialectName).Append(new TableValuedParameter(paramName, relation))); }
public static CommandBuffer Update <TSource>(this CommandBuffer buffer, TSource source, RelationHeader sourceHeader) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } if (buffer.Store == null) { throw CommandException.NoSchemaStoreAttached(); } IRelation relation = new Relation(buffer.Store.From(source), sourceHeader); buffer.Update(relation); return(buffer); }
public static QueryBuffer Insert <TSource>(this QueryBuffer buffer, TSource source, RelationHeader sourceHeader) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } IRelation relation = new Relation(buffer.Store.From(source), sourceHeader); buffer.Insert(relation); return(buffer); }