public static string DbTypeLength(string dbtype, string datatype, string Length)
        {
            string result = "";

            switch (dbtype)
            {
            case "SQL2000":
            case "SQL2005":
            case "SQL2008":
            case "SQL2012":
                result = CodeCommon.DbTypeLengthSQL(dbtype, datatype, Length);
                break;

            case "Oracle":
                result = CodeCommon.DbTypeLengthOra(datatype, Length);
                break;

            case "MySQL":
                result = CodeCommon.DbTypeLengthMySQL(datatype, Length);
                break;

            case "OleDb":
                result = CodeCommon.DbTypeLengthOleDb(datatype, Length);
                break;

            case "SQLite":
                result = CodeCommon.DbTypeLengthSQLite(datatype, Length);
                break;
            }
            return(result);
        }
        public static string CSToProcType(string DbType, string cstype)
        {
            string result = cstype;

            switch (DbType)
            {
            case "SQL2000":
            case "SQL2005":
            case "SQL2008":
            case "SQL2012":
                result = CodeCommon.CSToProcTypeSQL(cstype);
                break;

            case "Oracle":
                result = CodeCommon.CSToProcTypeOra(cstype);
                break;

            case "MySQL":
                result = CodeCommon.CSToProcTypeMySQL(cstype);
                break;

            case "OleDb":
                result = CodeCommon.CSToProcTypeOleDb(cstype);
                break;

            case "SQLite":
                result = CodeCommon.CSToProcTypeSQLite(cstype);
                break;
            }
            return(result);
        }
        private static string DbTypeLengthMySQL(string datatype, string Length)
        {
            string text = "";
            string key;

            switch (key = datatype.Trim().ToLower())
            {
            case "number":
                if (Length == "")
                {
                    text = "4";
                    goto IL_139;
                }
                text = Length;
                goto IL_139;

            case "varchar2":
                if (Length == "")
                {
                    text = "50";
                    goto IL_139;
                }
                text = Length;
                goto IL_139;

            case "char":
                if (Length == "")
                {
                    text = "50";
                    goto IL_139;
                }
                text = Length;
                goto IL_139;

            case "date":
            case "nchar":
            case "nvarchar2":
            case "long":
            case "long raw":
            case "bfile":
            case "blob":
                goto IL_139;
            }
            text = Length;
IL_139:
            if (text != "")
            {
                text = CodeCommon.CSToProcType("MySQL", datatype) + "," + text;
            }
            else
            {
                text = CodeCommon.CSToProcType("MySQL", datatype);
            }
            return(text);
        }
        private static string DbTypeLengthSQL(string dbtype, string datatype, string Length)
        {
            string text = CodeCommon.GetDataTypeLenVal(datatype, Length);
            string result;

            if (text != "")
            {
                if (text == "MAX")
                {
                    text = "-1";
                }
                result = CodeCommon.CSToProcType(dbtype, datatype) + "," + text;
            }
            else
            {
                result = CodeCommon.CSToProcType(dbtype, datatype);
            }
            return(result);
        }
        public static string GetWhereParameterExpression(List <ColumnInfo> keys, bool IdentityisPrior, string DbType)
        {
            StringPlus stringPlus  = new StringPlus();
            ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys);
            bool       flag        = CodeCommon.HasNoIdentityKey(keys);

            //if (flag)
            //{
            //    //没有自增列  用主键
            //    foreach (ColumnInfo current in keys)
            //    {
            //        if (current.IsPrimaryKey)
            //        {
            //            stringPlus.Append(current.ColumnName + "=" + CodeCommon.preParameter(DbType) + current.ColumnName);
            //        }
            //    }
            //}
            //else
            if ((IdentityisPrior && identityKey != null) || (!flag && identityKey != null))
            {
                stringPlus.Append(identityKey.ColumnName + "=" + CodeCommon.preParameter(DbType) + identityKey.ColumnName);
            }
            else
            {
                foreach (ColumnInfo current in keys)
                {
                    if (current.IsPrimaryKey || !current.IsIdentity)
                    {
                        stringPlus.Append(string.Concat(new string[]
                        {
                            current.ColumnName,
                            "=",
                            CodeCommon.preParameter(DbType),
                            current.ColumnName,
                            " and "
                        }));
                    }
                }
                stringPlus.DelLastChar("and");
            }
            return(stringPlus.Value);
        }
        public static string GetFieldstrlistAdd(List <ColumnInfo> keys, bool IdentityisPrior)
        {
            StringPlus stringPlus  = new StringPlus();
            ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys);

            if (IdentityisPrior && identityKey != null)
            {
                stringPlus.Append(identityKey.ColumnName);
            }
            else
            {
                foreach (ColumnInfo current in keys)
                {
                    if (current.IsPrimaryKey || !current.IsIdentity)
                    {
                        stringPlus.Append(current.ColumnName + "+");
                    }
                }
                stringPlus.DelLastChar("+");
            }
            return(stringPlus.Value);
        }
        public static string GetInParameter(List <ColumnInfo> keys, bool IdentityisPrior)
        {
            StringPlus stringPlus  = new StringPlus();
            ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys);

            if (IdentityisPrior && identityKey != null)
            {
                stringPlus.Append(CodeCommon.DbTypeToCS(identityKey.TypeName) + " " + identityKey.ColumnName);
            }
            else
            {
                foreach (ColumnInfo current in keys)
                {
                    if (current.IsPrimaryKey || !current.IsIdentity)
                    {
                        stringPlus.Append(CodeCommon.DbTypeToCS(current.TypeName) + " " + current.ColumnName + ",");
                    }
                }
                stringPlus.DelLastComma();
            }
            return(stringPlus.Value);
        }
        public static string GetWhereExpression(List <ColumnInfo> keys, bool IdentityisPrior)
        {
            StringPlus stringPlus  = new StringPlus();
            ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys);

            if (IdentityisPrior && identityKey != null)
            {
                if (CodeCommon.IsAddMark(identityKey.TypeName))
                {
                    stringPlus.Append(identityKey.ColumnName + "='\"+" + identityKey.ColumnName + "+\"'");
                }
                else
                {
                    stringPlus.Append(identityKey.ColumnName + "=\"+" + identityKey.ColumnName + "+\"");
                }
            }
            else
            {
                foreach (ColumnInfo current in keys)
                {
                    if (current.IsPrimaryKey || !current.IsIdentity)
                    {
                        if (CodeCommon.IsAddMark(current.TypeName))
                        {
                            stringPlus.Append(current.ColumnName + "='\"+" + current.ColumnName + "+\"' and ");
                        }
                        else
                        {
                            stringPlus.Append(current.ColumnName + "=\"+" + current.ColumnName + "+\" and ");
                        }
                    }
                }
                stringPlus.DelLastChar("and");
            }
            return(stringPlus.Value);
        }
        public static string GetPreParameter(List <ColumnInfo> keys, bool IdentityisPrior, string DbType)
        {
            StringPlus stringPlus  = new StringPlus();
            StringPlus stringPlus2 = new StringPlus();

            stringPlus.AppendSpaceLine(3, CodeCommon.DbParaHead(DbType) + "Parameter[] parameters = {");
            ColumnInfo identityKey = CodeCommon.GetIdentityKey(keys);
            bool       flag        = CodeCommon.HasNoIdentityKey(keys);

            if ((IdentityisPrior && identityKey != null) || (!flag && identityKey != null))
            {
                stringPlus.AppendSpaceLine(5, string.Concat(new string[]
                {
                    "new ",
                    CodeCommon.DbParaHead(DbType),
                    "Parameter(\"",
                    CodeCommon.preParameter(DbType),
                    identityKey.ColumnName,
                    "\", ",
                    CodeCommon.DbParaDbType(DbType),
                    ".",
                    CodeCommon.DbTypeLength(DbType, identityKey.TypeName, ""),
                    ")"
                }));
                stringPlus2.AppendSpaceLine(3, "parameters[0].Value = " + identityKey.ColumnName + ";");
            }
            else
            {
                int num = 0;
                foreach (ColumnInfo current in keys)
                {
                    if (current.IsPrimaryKey || !current.IsIdentity)
                    {
                        stringPlus.AppendSpaceLine(5, string.Concat(new string[]
                        {
                            "new ",
                            CodeCommon.DbParaHead(DbType),
                            "Parameter(\"",
                            CodeCommon.preParameter(DbType),
                            current.ColumnName,
                            "\", ",
                            CodeCommon.DbParaDbType(DbType),
                            ".",
                            CodeCommon.DbTypeLength(DbType, current.TypeName, current.Length),
                            "),"
                        }));
                        stringPlus2.AppendSpaceLine(3, string.Concat(new string[]
                        {
                            "parameters[",
                            num.ToString(),
                            "].Value = ",
                            current.ColumnName,
                            ";"
                        }));
                        num++;
                    }
                }
                stringPlus.DelLastComma();
            }
            stringPlus.AppendSpaceLine(3, "};");
            stringPlus.Append(stringPlus2.Value);
            return(stringPlus.Value);
        }
        private static string DbTypeLengthSQLite(string datatype, string Length)
        {
            string text = "";
            string key;

            switch (key = datatype.Trim())
            {
            case "int":
            case "integer":
                if (Length == "")
                {
                    text = "4";
                    goto IL_231;
                }
                text = Length;
                goto IL_231;

            case "varchar":
                if (Length == "")
                {
                    text = "50";
                    goto IL_231;
                }
                text = Length;
                goto IL_231;

            case "char":
                if (Length == "")
                {
                    text = "50";
                    goto IL_231;
                }
                text = Length;
                goto IL_231;

            case "bit":
                text = "1";
                goto IL_231;

            case "float":
            case "numeric":
            case "decimal":
            case "money":
            case "smallmoney":
            case "binary":
            case "smallint":
            case "bigint":
            case "blob":
                text = Length;
                goto IL_231;

            case "image":
            case "datetime":
            case "smalldatetime":
            case "nchar":
            case "nvarchar":
            case "ntext":
            case "text":
            case "time":
            case "date":
            case "boolean":
                goto IL_231;
            }
            text = Length;
IL_231:
            if (text != "")
            {
                text = CodeCommon.CSToProcType("SQLite", datatype) + "," + text;
            }
            else
            {
                text = CodeCommon.CSToProcType("SQLite", datatype);
            }
            return(text);
        }