Is specifying a field name on middle-tier a leaky abstraction?
I feel it is too cumbersome to create a separate function just for each field, even if it is code-generated.
public bool Assortment_IsValueExistingOnOtherRecord(
Dictionary<string, object> exceptPkColumns,
string field, object value
)
{
var c = Connect();
var dt = new DataTable();
string sanitizedField = field.Replace("'","");
var daAssortment = new SqlDataAdapter(
string.Format(
@"SELECT 1 FROM assortment
WHERE
/* do I violate any good programming practice here? */ [{0}] = @value
AND NOT (assortment_id = @assortment_id)", field), c);
daAssortment.SelectCommand.Parameters.Add("assortment_id", exceptPkColumns["assortment_id"]);
daAssortment.SelectCommand.Parameters.Add("value", value);
daAssortment.Fill(dt);
return dt.Rows.Count == 1;
}