Consider the following two overloaded functions. The first one just wraps the single value into a list and passes to the one that takes in multiple values.
I feel like the overloaded single function isn't needed. Is there an easy yet not too hacky method for having just 1 function that can handle a single or an enumerable ?
public static void Insert<T>(EntityType entityType, long entityId, string shortName, T value, string owner = null, OptionSearch optionSearch = OptionSearch.Name)
{
Insert(entityType, entityId, shortName, new List<T> {value}, owner, optionSearch);
}
public static void Insert<T>(EntityType entityType, long entityId, string shortName, IEnumerable<T> values, string owner = null, OptionSearch optionSearch = OptionSearch.Name)
{
// Do all the stuff and things using a list of values.
}
Normally I wouldn't care about the overload but with all these parameters (and making them one input object isn't an option) it just makes it seem unneeded.
PS: Related Passing a single item as IEnumerable<T> but that only discusses ways of doing the overload not so much how to get rid of it