Esempio n. 1
0
 public ProcPage(IProjection model, IProjection result)
 {
     this.M       = model?.Cast <TModel>() ?? throw new ArgumentNullException(nameof(model));
     this.R       = result?.Cast <TResult>() ?? throw new ArgumentNullException(nameof(result));
     this.Context = model.Context;
     this.Model   = (TModel)this.M.Attr().Field?.Invoke()?.Value;
 }
Esempio n. 2
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));
            }
        }
Esempio n. 3
0
 public ProcPage(IProjection model, IProjection result)
 {
     this.M       = model?.Cast <TModel>() ?? throw new ArgumentNullException(nameof(model));
     this.R       = result?.Cast <TResult>() ?? throw new ArgumentNullException(nameof(result));
     this.Context = model.Context;
     this.Model   = (TModel)(this.M.Attr().Data?.Source.Snapshot ?? default);
 }
 public ProjectionAttribute(ProjectionIdentity identity, IProcContext context, IProjectionMetadata metadata, IProjectionData data)
 {
     this.Identity = identity ?? throw ProjectionException.ArgumentNull(nameof(identity), metadata);
     this.Context  = context ?? throw ProjectionException.ArgumentNull(nameof(context), metadata);
     this.Metadata = metadata ?? throw ProjectionException.ArgumentNull(nameof(metadata), metadata);
     this.Data     = data;
     this.Content  = SqlContent.Empty;
 }
Esempio n. 5
0
 public Projection(ProjectionIdentity identity, IProcContext context, IProjectionMetadata metadata)
 {
     this.Identity = identity ?? throw ProjectionException.ArgumentNull(nameof(identity), metadata);
     this.Context  = context ?? throw ProjectionException.ArgumentNull(nameof(context), metadata);
     this.Metadata = metadata;
     this.Data     = ProjectionData.Resolve(identity);
     this.Options  = ProjectionOptions.Default;
     this.Header   = this.CreateDefaultHeader(metadata);
 }
Esempio n. 6
0
 internal Projection(IProjectionIdentity identity, IProcContext context, IProjectionMetadata metadata)
 {
     this.Identity   = identity ?? throw ProjectionException.ArgumentNull(nameof(identity));
     this.Context    = context ?? throw ProjectionException.ArgumentNull(nameof(context));
     this.Metadata   = metadata ?? throw ProjectionException.FromAttribute(identity.Schema.Model, null, message: "Projection metadata not found.");
     this.Source     = identity.Field;
     this.Options    = new ProjectionOptions();
     this.Attributes = this.CreateDefaultAttributes(this.Metadata);
 }
        public ProjectionValues(IProcContext context, ProjectionIdentity identity, IEnumerable <IProjection <TItem> > items, int batchIndex = -1)
        {
            this.Context    = context ?? throw new ArgumentNullException(nameof(context));
            this.Identity   = identity ?? throw new ArgumentNullException(nameof(identity));
            this.Items      = items ?? throw new ArgumentNullException(nameof(identity));
            this.BatchIndex = batchIndex;

            if (this.Items is IProjectionValues <TItem> innerValues)
            {
                this.Items = innerValues.Items;
            }
        }
Esempio n. 8
0
        public virtual IProjection <TModel> GetProjection <TModel>(IProcContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            ISchema             schema   = context.Domain.Schemas.GetSchema(typeof(IList <TModel>));
            IProjectionMetadata metadata = schema.Require <IProjectionMetadata>();

            ProjectionIdentity identity = new ProjectionIdentity(schema);

            return(new Projection <TModel>(identity, context, metadata.Item ?? metadata));
        }
Esempio n. 9
0
        public virtual IProjection <TModel> GetProjection <TModel>(IProcContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            ISchema             schema   = context.Domain.Schemas.GetSchema(typeof(IList <TModel>));
            IProjectionMetadata metadata = schema.GetMetadata <IProjectionMetadata>();

            if (metadata == null)
            {
                throw new ProjectionException("Unable to locate projection metadata for model.");
            }

            ProjectionIdentity identity = new ProjectionIdentity(schema);

            return(new Projection <TModel>(identity, context, metadata.Item ?? metadata));
        }
Esempio n. 10
0
 public Projection(IProjectionIdentity identity, IProcContext context)
     : base(identity, context)
 {
 }
Esempio n. 11
0
 internal Projection(IProjectionIdentity identity, IProcContext context, IProjectionMetadata metadata)
     : base(identity, context, metadata)
 {
 }
Esempio n. 12
0
 public Projection(ProjectionIdentity identity, IProcContext context, IProjectionMetadata metadata)
     : base(identity, context, metadata)
 {
 }