private string GetQueryMethod(SPlist param, string MethodName = default(string))
        {
            string paramName = string.IsNullOrEmpty(MethodName) ? param.ClassName : MethodName;

            if (string.IsNullOrEmpty(MethodName) && string.IsNullOrEmpty(param.ClassName))
            {
                paramName = param.Spname;
                paramName = paramName.Replace("[", "");
                paramName = paramName.Replace("]", "");
                // paramName = paramName.Replace(".", "");
                if (paramName.Contains('.'))
                {
                    paramName = paramName.Split('.')[1];
                }
            }

            if (param.IsNonQuery)
            {
                return($"_SpHelper.NonQuery(SP.{paramName},param)");
            }
            else
            {
                return($"_SpHelper.Query<{paramName}Result>(SP.{paramName},param)");
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string clasName  = this.txtClassName.Text?.Trim();
            string spName    = this.txtSpName.Text?.Trim();
            string conStr    = Home.Constr;
            string NameSpace = this.textBox1.Text?.Trim();
            SPlist sp        = new SPlist();

            sp.Spname     = spName;
            sp.ClassName  = clasName;
            sp.MethodName = txtMethod.Text;
            sp.IsNonQuery = checkBox2.Checked;
            sp.IsSingle   = checkBox3.Checked;

            SpParamResultDetail m = new CodeGenerator().GenerateModel(spName, clasName, _constr, NameSpace);

            if (checkBox1.Checked)
            {
                if (string.IsNullOrEmpty(txtMethod.Text))
                {
                    MessageBox.Show("Provide Name for Repo Method");
                }
                else
                {
                    m.RepoMethod = new CodeGenerator().GenerateRepoMethod(sp);
                }
            }

            SpParamClass objparam = new SpParamClass(m);

            objparam.ShowDialog();
        }
        public string GenerateRepoMethod(SPlist sp, string MethodName = default(string))
        {
            string methodName = sp.MethodName ?? $"Execute{sp.Spname}";

            methodName = methodName.Replace("[", "");
            methodName = methodName.Replace("]", "");
            methodName = methodName.Replace(".", "");
            sbuilder.Append($"\n \t \t \t public {GetRetunType(sp)} {methodName} ({GetParamType(sp)} param) => {GetQueryMethod(sp)} ");
            return(sbuilder.ToString());
        }
        private string GetParamType(SPlist param)
        {
            string paramName = param.ClassName;

            if (string.IsNullOrEmpty(param.ClassName))
            {
                paramName = param.Spname;
                paramName = paramName.Replace("[", "");
                paramName = paramName.Replace("]", "");
                paramName = paramName.Replace(".", "");
            }
            return($"{paramName}Param");
        }
Example #5
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNameSpace.Text))
            {
                MessageBox.Show("Prove Value for Name space ");
                return;
            }

            List <SPlist> lst  = new List <SPlist>();
            CodeGenerator _gen = new CodeGenerator();

            for (int rows = 0; rows < dataGridView1.Rows.Count; rows++)
            {
                SPlist obj = new SPlist();
                obj.Spname     = dataGridView1.Rows[rows].Cells["spname"].Value?.ToString();
                obj.ClassName  = dataGridView1.Rows[rows].Cells["Classname"].Value?.ToString();
                obj.MethodName = dataGridView1.Rows[rows].Cells["MethodName"].Value?.ToString();
                obj.IsNonQuery = Convert.ToBoolean(dataGridView1.Rows[rows].Cells["IsNonQuery"].Value);
                obj.IsSingle   = Convert.ToBoolean(dataGridView1.Rows[rows].Cells["IsSingle"].Value);
                if (!string.IsNullOrEmpty(obj.Spname))
                {
                    lst.Add(obj);
                }
            }
            SpParamResultDetail m = _gen.GenerateModel(lst, Home.Constr, txtNameSpace.Text);

            m.Consts = _gen.GenerateConsts(lst);

            if (checkBox1.Checked)
            {
                if (!string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrEmpty(textBox2.Text))
                {
                    m.Repo = _gen.GenerateRepo(lst, textBox2.Text, textBox3.Text);
                }

                else
                {
                    MessageBox.Show("Please provide Value for Repo Namesapce and Repo class");
                }
            }

            SpParamClass objparam = new SpParamClass(m);

            objparam.ShowDialog();
        }
        private string GetRetunType(SPlist param)
        {
            if (param.IsNonQuery)
            {
                return("bool");
            }
            if (param.IsSingle)
            {
                return(param.ClassName);
            }
            string returnTypeName = param.ClassName;

            if (string.IsNullOrEmpty(param.ClassName))
            {
                returnTypeName = param.Spname;
                returnTypeName = returnTypeName.Replace("[", "");
                returnTypeName = returnTypeName.Replace("]", "");
                returnTypeName = returnTypeName.Replace(".", "");
            }


            return($"List<{returnTypeName}Result>");
        }