/// <summary> /// Converts collection of keyvaluepair of int and bool for use to pass as table valued parameter. /// Stored procedure parameter must be of type tt_int_bit. /// </summary> /// <param name="values">Dictionary of int and bool</param> /// <returns>DictionaryIntStringCollection type that implements IEnumerable SqlDataRecord</returns> public static object ToTableType(this IEnumerable <KeyValuePair <int, bool> > values) { if ((values == null) || (values.Count() == 0)) { return(IntBoolCollection.EmptyTable); } else { IntBoolCollection collection = new IntBoolCollection(); foreach (var item in values) { collection.Add(item); } return(collection); } }
/// <summary> /// Converts dictionary of int and bool for use to pass as table valued parameter. /// Stored procedure parameter must be of type tt_int_bit. /// </summary> /// <param name="values">Dictionary of int and bool</param> /// <returns>DictionaryIntStringCollection type that implements IEnumerable SqlDataRecord</returns> public static object ToTableType(this Dictionary <int, bool> values) { if ((values == null) || (values.Count == 0)) { return(IntBoolCollection.EmptyTable); } else { IntBoolCollection collection = new IntBoolCollection(); foreach (var item in values) { collection.Add(new KeyValuePair <int, bool>(item.Key, item.Value)); } return(collection); } }