예제 #1
0
        //private readonly string Temp_Query_Model = Comm.GetTemplete("Query.Model.cshtml");
        //private readonly string Temp_Query_GetList = Comm.GetTemplete("Query.GetList.cshtml");
        //private readonly string Temp_Query_GetOne = Comm.GetTemplete("Query.GetOne.cshtml");
        //private readonly string Temp_Query_ExecuteNonQuery = Comm.GetTemplete("Query.ExecuteNonQuery.cshtml");
        //private readonly string Temp_Query_ExecuteScalar = Comm.GetTemplete("Query.ExecuteScalar.cshtml");
        //private readonly string Temp_Query_GetMultiList = Comm.GetTemplete("Query.GetMultiList.cshtml");

        public string GenForQueryList(string query, Module module, string connstr)
        {
            DbQueryGetListModel gModel = new DbQueryGetListModel();
            gModel.SQL = query;
            gModel.ConnectionString = connstr;
            gModel.Module = module;
            //if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
            //{
            //    for (int i = 0; i < ds.Tables.Count; i++)
            //    {
            //        DataTable dt = ds.Tables[i];
            //        Module module = new Module();
            //        module.ModuleName = string.Format("Result{0}", i);
            //        module.CodeName = string.Format("Result{0}", i);
            //        foreach (DataColumn dc in dt.Columns)
            //        {
            //            ModuleField mf = new ModuleField(module, "", dc.ColumnName, dc.ColumnName);
            //            mf.DataType = dc.DataType;
            //            mf.Nullable = dc.AllowDBNull;
            //            mf.LanguageType = LanguageConvert.GetCSharpType(dc.DataType, dc.AllowDBNull);
            //            //Debug.WriteLine("{0} ---> {1}", mf.FieldName, mf.LanguageType);
            //            module.Fields.Add(mf);
            //        }

            //        gModel.Module = module;
            //    }
            //}

            string modelCode = GenModelCode(gModel.Module);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(modelCode);

            string queryCode = codeGen.Gen(Comm.GetTemplete("Query.GetList.cshtml"), gModel);
            queryCode = queryCode.Replace("'conn_name'", "Program.TestConnection");
            sb.AppendLine(queryCode);

            return sb.ToString();
        }
예제 #2
0
        public string GenForExecuteNoQuery(string query, string connstr)
        {
            DbQueryGetListModel gModel = new DbQueryGetListModel();
            gModel.SQL = query;
            gModel.ConnectionString = connstr;

            StringBuilder sb = new StringBuilder();

            string queryCode = codeGen.Gen(Comm.GetTemplete("Query.ExecuteNonQuery.cshtml"), gModel);
            queryCode = queryCode.Replace("'conn_name'", "Program.TestConnection");
            sb.AppendLine(queryCode);

            return sb.ToString();
        }