Beispiel #1
0
        private IEnumerable <IProjectionAttribute> CreateDefaultHeader(IProjectionMetadata metadata)
        {
            ProjectionIdentity identity = this.Identity;
            IProcContext       context  = this.Context;
            IEnumerable <IProjectionMetadata> header = this.SelectAttributes(metadata);

            if (this.Data != null)
            {
                using ProjectionReader reader = new ProjectionReader(this.Data.Source, header);

                if (reader.Read())
                {
                    foreach (var(valueMetadata, data) in header.Zip(reader.GetData()))
                    {
                        yield return(new ProjectionAttribute(identity, context, valueMetadata, data));
                    }

                    yield break;
                }
            }

            foreach (IProjectionMetadata attributeMetadata in header)
            {
                yield return(new ProjectionAttribute(identity, context, attributeMetadata, data: null));
            }
        }
        public static IEnumerable <IProjectionData> Lookup(IField source, IEnumerable <IProjectionMetadata> header)
        {
            using ProjectionReader reader = new ProjectionReader(source, header);

            if (reader.Read())
            {
                foreach (IProjectionData data in reader.GetData())
                {
                    yield return(data);
                }
            }
        }
 internal static IProjectionData Resolve(IProjectionData data, IProjectionMetadata metadata)
 {
     if (data == null)
     {
         return(null);
     }
     else if (data.Source.Metadata == metadata.Relation)
     {
         return(data);
     }
     else
     {
         return(ProjectionReader.Lookup(data.Source, new[] { metadata }).FirstOrDefault());
     }
 }