/// <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.Source == null) { throw ProjectionException.ValueNotFound(projection); } else if (!projection.Attributes.Any()) { throw ProjectionException.FromProjection(projection, "No attributes found."); } Relation relation = new Relation(projection.Source, projection.Attributes.Select(a => a.Metadata.Identity)); string paramName = projection.Context.Lookup.Custom("TP", projection.Identity, field: projection.Source); string dialectName = projection.Context.Domain.Dialect.Parameter(paramName); return(projection.Attr().Append(dialectName).Append(new TableValuedParameter(paramName, relation))); }
/// <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))); }
/// <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.Source == null) { throw ProjectionException.ValueNotFound(projection); } else if (!projection.Attributes.Any()) { throw ProjectionException.FromProjection(projection, "No attributes found."); } IProjectionMetadata metadata = TvpHelper.GetPreferredTvpMetadata(projection); IField source = new Relation(projection.Source, metadata.Identity.Name).Scalar(); RelationIdentity identity = new RelationIdentity(metadata.Identity.Schema, projection.Attributes.Select(a => a.Metadata.Identity)); IBindingParameterContract contract = TvpCache.GetParameterContract(identity); string paramName = projection.Context.Lookup.Custom("TP", projection.Identity, field: source); string dialectName = projection.Context.Domain.Dialect.Parameter(paramName); return(projection.Attr().Append(dialectName).Append(new Parameter(paramName, source, contract))); }
public static IEnumerable <IProjection> Vals(this IProjection projection) { if (projection.Source == null) { yield break; } IEnumerable <MetadataIdentity> heading = new[] { projection.Attr().Metadata.Identity }.Concat(projection.Attributes.Select(a => a.Metadata.Identity)); Relation relation = new Relation(projection.Source, heading); IProjectionAttribute[] attributes = projection.Attributes.ToArray(); foreach (ITuple tuple in relation) { IField field = tuple[0]; IProjectionAttribute[] newAttributes = attributes.Select((a, i) => a.With(field: () => tuple[i + 1])).ToArray(); yield return(projection.With(attributes: newAttributes, field: field)); projection.Context.Execution.Buffer.Mark(); } }
public static IProjectionAttribute ValList(this IProjection projection, Func <IProjectionAttribute, IProjectionAttribute> itemFactory) { if (projection.Source == null) { throw ProjectionException.ValueNotFound(projection); } IField[] items = new Relation(projection.Source, projection.Metadata.Identity.Name).Column().ToArray(); IProjectionAttribute attribute = projection.Attr(); if (items.Length == 0) { return(attribute); } attribute = itemFactory(attribute.With(metadata: attribute.Metadata, field: () => items[0])); foreach (IField item in items.Skip(1)) { attribute = itemFactory(attribute.With(field: () => item).Append(", ")); } return(attribute); }
/// <summary> /// Appends the current parameter name and value, e.g. <c>@P0</c>, to a new attribute buffer. /// </summary> /// <param name="projection">The current projection.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Par(this IProjection projection) => projection.Attr().Par();
/// <summary> /// Appends the current table alias, e.g. <c>T0</c>, to a new attribute buffer. /// </summary> /// <param name="projection">The current projection.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Ali(this IProjection projection) => projection.Attr().Ali();
/// <summary> /// Appends the current table name, e.g. <c>"MyTable"</c>, to a new attribute buffer. /// </summary> /// <param name="projection">The current projection.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute TblName(this IProjection projection) => projection.Attr().TblName();
/// <summary> /// Appends the current correlated table name, e.g. <c>"MyTable" T0</c>, to a new attribute buffer. /// </summary> /// <param name="projection">The current projection.</param> /// <param name="tblAlias">An alternative alias to use for the current table.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Tbl(this IProjection projection, string tblAlias = null) => projection.Attr().Tbl(tblAlias);
public static bool HasVal <TModel, TProperty>(this IProjection <TModel> projection, Expression <Func <TModel, TProperty> > expression) => projection.Attr(expression).HasVal();
/// <summary> /// Appends the current property name, e.g. <c>"Item.MyValue"</c>, to a new attribute buffer. /// </summary> /// <param name="projection">The current projection</param> /// <param name="tblAlias">An alias to qualify the property name with.</param> /// <param name="propName">A name to suffix the property name with.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Prop(this IProjection projection, string tblAlias = null, string propName = null) => projection.Attr().Prop(tblAlias, propName);
/// <summary> /// Appends the selected property name, e.g. <c>"Item.MyValue"</c>, to a new attribute buffer. /// </summary> /// <param name="projection">The current projection</param> /// <param name="expression">Expression selecting a specific attribute.</param> /// <param name="tblAlias">An alias to qualify the property name with.</param> /// <param name="propName">A name to suffix the property name with.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Prop <TModel, TProperty>(this IProjection <TModel> projection, Expression <Func <TModel, TProperty> > expression, string tblAlias = null, string propName = null) => projection.Attr(expression).Prop(tblAlias, propName);
/// <summary> /// Navigates to the selected attribute and appends the current column name in qualified form, e.g. <c>T0."MyColumn"</c>, to the attribute buffer. /// </summary> /// <param name="projection">The current projection</param> /// <param name="expression">Expression selecting a specific attribute.</param> /// <param name="tblAlias">The table alias to qualify the column name with.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Col <TModel, TProperty>(this IProjection <TModel> projection, Expression <Func <TModel, TProperty> > expression, string tblAlias = null) => projection.Attr(expression).Col(tblAlias);
public static IProjectionAttribute Refcursor(this IProjection projection) => projection.Attr().Refcursor();
/// <summary> /// Appends the selected JSON path literal, e.g. <c>'$.my.value'</c>, to the attribute buffer. /// </summary> /// <param name="projection">The current projection.</param> /// <param name="expression">Expression selecting a projection target.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute JsonPath <TModel, TProperty>(this IProjection <TModel> projection, Expression <Func <TModel, TProperty> > expression) => projection.Attr(expression).JsonPath();
/// <summary> /// Appends the current value in safe literal form, e.g. <c>1</c>, to a new attribute buffer. Parameters are used for unsafe literals. /// </summary> /// <param name="projection">The current attribute.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Lit(this IProjection projection) => projection.Attr().Lit();
/// <summary> /// Appends the selected value in safe literal form, e.g. <c>1</c>, to a new attribute buffer. Parameters are used for unsafe literals. /// </summary> /// <param name="projection">The current attribute.</param> /// <param name="expression">Expression selecting a specific attribute.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Lit <TModel, TProperty>(this IProjection <TModel> projection, Expression <Func <TModel, TProperty> > expression) => projection.Attr(expression).Lit();
/// <summary> /// Appends a call to <c>JSON_VALUE</c> from the current column and JSON path, e.g. <c>JSON_VALUE(T0."MyJson", '$.my.value')</c>, to a new attribute buffer. /// </summary> /// <param name="projection">The current projection.</param> /// <returns>A new attribute containing the appended buffer.</returns> public static IProjectionAttribute Json(this IProjection projection) => projection.Attr().Json();