示例#1
0
        /// <summary>
        /// 获取in的sql
        /// </summary>
        /// <param name="tableNameOrAlias"></param>
        /// <param name="columnName"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public static SqlConstructor GetInSql(string tableNameOrAlias, string columnName, IEnumerable <string> values)
        {
            SqlConstructor result = new SqlConstructor();

            if (values != null && values.Any())
            {
                result.Sql.AppendFormat(" {0}.{1} IN (", tableNameOrAlias, columnName);
                int i = 100;
                foreach (var v in values)
                {
                    i++;
                    result.Sql.AppendFormat("@{0}{1},", columnName, i);
                    result.Parameters.Add(DbParameterFactory.CreateDbParameter(columnName + i.ToString(), v));
                }
                result.Sql.Remove(result.Sql.Length - 1, 1);
                result.Sql.Append(") ");
                result.HasSql = true;
            }
            return(result);
        }
示例#2
0
 /// <summary>
 /// 参数准备
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public DbParameter GetDbParameter(string name, object value)
 {
     return(DbParameterFactory.CreateDbParameter(name, value));
 }