Ejemplo n.º 1
0
        /// <summary>
        /// BaseApi(DBHelper dbh, string rS, string cS, string reS, string dtS): 有五个参数的构造函数
        /// </summary>
        /// <param name="dbh">DBHelper对象</param>
        /// <param name="rS">行分隔符</param>
        /// <param name="cS">列分隔符</param>
        /// <param name="reS">结果集分隔符</param>
        /// <param name="dtS">数据类型, 可以使json, array, html 三种格式 默认是html</param>
        private void initClass(DBHelper dbh, string rS, string cS, string reS, string dtS)
        {
            if (Native.isNullEmpty(rS))
            {
                rS = "\u0002";
            }
            if (Native.isNullEmpty(cS))
            {
                cS = "\u0001";
            }
            if (Native.isNullEmpty(reS))
            {
                reS = "\u0003";
            }
            if (Native.isNullEmpty(dtS))
            {
                dtS = "html";
            }
            setDBHelper(dbh);
            setRSplit(rS);
            setCSplit(cS);
            setReSplit(reS);
            setDataType(dtS);
            MConvert.setKeySplit(',');
            DBUtil.setBaseApi(this);
            COL_FIELDS = new string[, ] {
                { "index", "col.colorder as idx" },
                { "name", "col.name as name" },
                { "ifMark", "(case when COLUMNPROPERTY(col.id, col.name, 'IsIdentity')=1 then '√'else '' end) as ifMask" },
                { "ifPrimaryKey", @"(case when (SELECT count(*)
			                              FROM sysobjects
			                              WHERE (name in
						                            (SELECT name
					                               FROM sysindexes
					                               WHERE (id = col.id) AND (indid in
								                             (SELECT indid
								                            FROM sysindexkeys
								                            WHERE (id = col.id) AND (colid in
										                              (SELECT colid
										                             FROM syscolumns
										                             WHERE (id = col.id) AND (name = col.name))))))) AND
												                            (xtype = 'PK'))>0 then '√' else '' end) as ifPrimaryKey"                                                 },
                { "defaultValue", "comments.text as defValue" },
                { "type", "types.name as type" },
                { "byte", "col.length as byte" },
                { "length", "COLUMNPROPERTY(col.id, col.name, 'PRECISION') as length" },
                { "decimalSize", "isnull(COLUMNPROPERTY(col.id,col.name,'Scale'),0) as decimalSize" },
                { "ifNull", "(case when col.isnullable=1 then '√'else '' end) as ifNull" },
                { "comment", "properties.value as comment" }
            };
        }