Example #1
0
        private static string ToSqlClause(KeyValuePair <string, object>[] conditions)
        {
            if (conditions == null)
            {
                return(string.Empty);
            }
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < conditions.Length; i++)
            {
                string op = (conditions[i].Value == null || conditions[i].Value is DBNull)?" IS ":"=";
                sb.Append(string.Format("{0}{1}{2}",
                                        SqlFormat.EscapeSql(conditions[i].Key), op,
                                        SqlFormat.ToSqlValueString(conditions[i].Value)));
                if (i != conditions.Length - 1)
                {
                    sb.Append(" AND ");
                }
            }
            return(sb.ToString());
        }