Exemplo n.º 1
0
        public ItemBuilder(RelationIdentity relation, MetadataIdentity source)
        {
            this.relation        = relation ?? throw new ArgumentNullException(nameof(relation));
            this.sourceMetadata  = source.GetMetadata <IRelationMetadata>();
            this.headingMetadata = relation.Heading.Select(m => m.GetMetadata <IRelationMetadata>()).ToArray();

            this.Validate();
        }
Exemplo n.º 2
0
        public static FuncDescriptor GetDescriptor(RelationIdentity relation, MetadataIdentity source)
        {
            FuncKey key = new FuncKey(relation, source);

            return(cache.GetOrAdd(key, _ =>
            {
                ListBuilder listBuilder = new ListBuilder(relation, source);
                RelationNode relationNode = listBuilder.Build();
                FuncBuilder funcBuilder = new FuncBuilder(relationNode);

                return funcBuilder.Build();
            }));
        }
Exemplo n.º 3
0
        public static IBindingParameterContract GetParameterContract(RelationIdentity relation)
        {
            if (relation == null)
            {
                throw new ArgumentNullException(nameof(relation));
            }

            return(Resolvers.GetOrAdd(relation, _ =>
            {
                IBindingMetadata[] bindings = relation.Heading.Select(m => m.GetMetadata <IBindingMetadata>()).ToArray();

                return TvpHelper.GetParameterContract(bindings);
            }));
        }
Exemplo n.º 4
0
        /// <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)));
        }
Exemplo n.º 5
0
 public ListBuilder(RelationIdentity relation, MetadataIdentity source)
 {
     this.relation = relation ?? throw new ArgumentNullException(nameof(relation));
     this.source   = source ?? throw new ArgumentNullException(nameof(source));
 }
Exemplo n.º 6
0
 public FuncKey(RelationIdentity relation, MetadataIdentity source)
 {
     this.Relation = relation ?? throw new ArgumentNullException(nameof(relation));
     this.Source   = source ?? throw new ArgumentNullException(nameof(source));
 }