public void DeleteCommand(IDbCommand command, object entity)
{
if (command == null) throw new ArgumentNullException("command");
if (entity == null) throw new ArgumentNullException("entity");
var where = "";
foreach (var property in _keys)
{
var value = property.GetValue(entity);
if (value == null || value == DBNull.Value)
throw new DataException(
string.Format("Entity {0}' do not contain a value for the key property '{1}'", entity,
property.PropertyName));
where += string.Format("{0}=" + "@{1} AND ", property.ColumnName, property.PropertyName);
command.AddParameter(property.PropertyName, value);
}
command.CommandText = string.Format("DELETE FROM {0} WHERE {1}",
TableName,
@where.Remove(@where.Length - 5, 5));
}