コード例 #1
0
        private string CreateEntityScript(string tableName, bool createFile = false)
        {
            Helper.VelocityHelper helper = new Helper.VelocityHelper("/tmpl/");
            string dbName = "";

            object obj = this.Invoke(new DelegateHelper.DGet(DelegateHelper.GetVal), comboBoxDb);

            if (null != obj)
            {
                dbName = obj.ToString();
            }

            List <DbColumn> list = core.GetDbColumns(dbName, tableName);

            helper.Put("EntityName", tableName);
            helper.Put("columns", list);
            if (list.Count > 0)
            {
                helper.Put("schema", list[0].TableSchema);
            }
            string identity = "";// list.Count > 0 ? list[0].IdentityKeys : "";

            helper.Put("identity", identity);
            helper.Put("namespace", !string.IsNullOrEmpty(tbNamespace.Text) ? tbNamespace.Text : "DAO");
            // dbcolumn

            string rsStr = helper.Render("Model.nm");

            if (createFile)
            {
                if (!string.IsNullOrEmpty(rsStr))
                {
                    object richText = this.Invoke(new DelegateHelper.DGet(DelegateHelper.GetVal), richTextBox1);
                    Helper.IO.FileHelper.WriteFile("Data\\" + tableName + ".cs", rsStr, Encoding.Default, false);
                }
            }
            return(rsStr);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: nkaluva/helper
        private string CreateEntityScript(string tableName, bool createFile = false)
        {
            Helper.VelocityHelper helper = new Helper.VelocityHelper("/tmpl/");
            string dbName = "";

            object obj = this.Invoke(new DelegateHelper.DGet(DelegateHelper.GetVal), comboBoxDb);

            if (null != obj) dbName = obj.ToString();

            List<DbColumn> list = core.GetDbColumns(dbName, tableName);
            helper.Put("EntityName", tableName);
            helper.Put("columns", list);
            if (list.Count > 0)
                helper.Put("schema", list[0].TableSchema);
            string identity = "";// list.Count > 0 ? list[0].IdentityKeys : "";
            helper.Put("identity", identity);
            helper.Put("namespace", !string.IsNullOrEmpty(tbNamespace.Text) ? tbNamespace.Text : "DAO");
            // dbcolumn

            string rsStr = helper.Render("Model.nm");
            if (createFile)
            {
                if (!string.IsNullOrEmpty(rsStr))
                {
                    object richText = this.Invoke(new DelegateHelper.DGet(DelegateHelper.GetVal), richTextBox1);
                    Helper.IO.FileHelper.WriteFile("Data\\" + tableName + ".cs", rsStr, Encoding.Default, false);
                }
            }
            return rsStr;
        }