public ProjectionAttribute(IProjection projection)
 {
     this.Identity = projection.Identity;
     this.Context  = projection.Context;
     this.Metadata = projection.Metadata;
     this.Data     = ProjectionData.Resolve(projection.Data, projection.Metadata);
     this.Content  = SqlContent.Empty;
 }
        public IProjectionAttribute With(IProjectionMetadata metadata = null, IProjectionData data = null, ISqlContent content = null)
        {
            IProjectionMetadata newMetadata = metadata ?? this.Metadata;
            IProjectionData     newData     = data ?? (metadata != newMetadata ? ProjectionData.Resolve(this.Data, newMetadata) : this.Data);
            ISqlContent         newContent  = content ?? this.Content;

            return(new ProjectionAttribute(this, newMetadata, newData, newContent));
        }
 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;
 }
Example #4
0
        public IProjectionAttribute With(IProjectionMetadata metadata = null, ISqlContent content = null, Func <IField> field = null)
        {
            IProjectionMetadata newMetadata = metadata ?? this.Metadata;
            ISqlContent         newContent  = content ?? this.Content;
            Func <IField>       newField    = field ?? (metadata != newMetadata ? this.GetValueFactory(this.Field?.Invoke()) : this.Field);

            return(new ProjectionAttribute(this, newMetadata, newContent, newField));
        }
Example #5
0
        public void Test_ProjectionAndInjection_WithServiceProvider()
        {
            PageDescriptor page   = this.locator.FindPage("DiQuery", typeof(DiAccessor));
            ProcEngine     engine = new ProcEngine(this.GetServiceProvider());

            ISqlContent result = engine.Proc(page, new ProcArgs(typeof(object), typeof(object)))(null).Buffer.ReadToEnd();

            result.Text.ShouldBe("SOMEVALUE+PROJ");
        }
Example #6
0
        public void Test_Projection_WithoutServiceProvider()
        {
            PageDescriptor page   = this.locator.FindPage("ProjectedQuery", typeof(MiscAccessor));
            ProcEngine     engine = new ProcEngine(null);

            ISqlContent result = engine.Proc(page, new ProcArgs(typeof(object), typeof(object)))(null).Buffer.ReadToEnd();

            result.Text.ShouldBe("PROJEXISTS");
        }
Example #7
0
        public void Append(ISqlContent content)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            this.bindings.AddRange(content.Bindings ?? Array.Empty <ICommandBinding>());
            this.parameters.AddRange(content.Parameters ?? Array.Empty <IParameter>());
            this.text.Append(content.Text);
        }
        protected ProjectionAttribute(IProjectionAttribute attribute, IProjectionMetadata metadata, IProjectionData data, ISqlContent content)
        {
            if (attribute == null)
            {
                throw ProjectionException.ArgumentNull(nameof(attribute), metadata);
            }

            this.Context  = attribute.Context;
            this.Identity = attribute.Identity;
            this.Metadata = metadata ?? throw ProjectionException.ArgumentNull(nameof(metadata), metadata);
            this.Data     = data;
            this.Content  = content ?? throw ProjectionException.ArgumentNull(nameof(content), metadata);
        }
Example #9
0
        //连接数据库
        private void Btn_connect_Click(object sender, EventArgs e)
        {
            //获取数据库类型
            string    jdbcType = cob_jdbctype.Text.Trim();
            string    jdbc     = txt_jdbcname.Text.Trim();
            string    user     = txt_user.Text.Trim();
            string    password = txt_password.Text.Trim();
            DataTable dt       = new DataTable();

            //sqlserver数据库
            if (jdbcType == "sqlserver")
            {
                string connect = string.Format("Data Source=.;Initial Catalog={0};uid={1};pwd={2};"
                                               , jdbc, user, password);
                sqlContent = new SqlConnect_Ms(connect);
                dt         = sqlContent.GetAllTableNames();
            }
            //mysql数据库
            else if (jdbcType == "mysql")
            {
                string connect = string.Format("server=127.0.0.1;port=3306;user={0};password={1}; database={2};"
                                               , user, password, jdbc);
                sqlContent = new SqlConnect_My(connect);
                dt         = sqlContent.GetAllTableNames();
            }
            MessageBox.Show("数据库连接成功", "提示", MessageBoxButtons.OK);

            List <string> items = new List <string>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                items.Add(dt.Rows[i]["TABLE_NAME"].ToString());
            }
            items.Sort();
            cob_tablename.Items.Clear();//先清除所有项
            cob_tablename.Items.AddRange(items.ToArray());
        }
Example #10
0
        private void Btn_connect_Click(object sender, EventArgs e)
        {
            //获取数据库类型
            string jdbcType = cob_jdbctype.Text.Trim();
            string jdbc     = txt_jdbcname.Text.Trim();
            string user     = txt_user.Text.Trim();
            string password = txt_password.Text.Trim();

            //sqlserver数据库
            if (jdbcType == "sqlserver")
            {
                string connect = string.Format("Data Source=.;Initial Catalog={0};uid={1};pwd={2};"
                                               , jdbc, user, password);
                sqlContent = new SqlConnect_Ms(connect);
            }
            //mysql数据库
            else if (jdbcType == "mysql")
            {
                string connect = string.Format("server=127.0.0.1;port=3306;user={0};password={1}; database={2};"
                                               , user, password, jdbc);
                sqlContent = new SqlConnect_My(connect);
            }
            MessageBox.Show("数据库连接成功", "提示", MessageBoxButtons.OK);
        }
Example #11
0
        protected ProjectionAttribute(IProjectionAttribute attribute, IProjectionMetadata metadata, ISqlContent content, Func <IField> field)
        {
            if (attribute == null)
            {
                throw ProjectionException.ArgumentNull(nameof(attribute), this);
            }

            this.Context  = attribute.Context;
            this.Identity = attribute.Identity;
            this.Metadata = metadata ?? throw ProjectionException.ArgumentNull(nameof(attribute), this);
            this.Content  = content ?? throw ProjectionException.ArgumentNull(nameof(content), this);
            this.Field    = field;
        }