Пример #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
 public DbParameter GetDbParameter(string parameterName, object value)
 {
     return(DbParameterFactory.CreateDbParameter(parameterName, value));
 }