Exemple #1
0
        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 ((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);
        }
Exemple #2
0
        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);
        }