using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; namespace MySystem { public static class StringBuilderExtension { public static void Condition(this StringBuilder input, string field, object val) { if(typeof(int) == val.GetType() || typeof(decimal) == val.GetType()) { input.Append(" and " + field + "=" + val); } else { input.Append(" and " + field + "='" + val + "'"); } } public static void ConditionLike(this StringBuilder input, string field, object val) { input.Append(" and " + field + " like '%" + val + "%'"); } } }