public MSSQLCommand MapParameters(Type baseType, object forObject, IDictionary <string, object?> parms) { BuildParameters(); var db = CEF.CurrentDBService(forObject); // The procedure signature is king - map underlying object to it, using and supplied name translations in scope foreach (var p in (from a in _cmd.Parameters.Cast <SqlParameter>() let sn = a.ParameterName.StartsWith("@") ? a.ParameterName.Substring(1) : a.ParameterName let pn = db?.GetPropertyNameFromStorageName(baseType, sn) ?? sn let hasVal = parms.ContainsKey(pn) where hasVal || UseNullForMissingValues select new { Parm = a, Value = hasVal ? parms[pn] : null, Name = pn })) { var val = p.Value; if (val != null) { if (val.GetType().Equals(typeof(DateTime))) { switch (ServiceScope.ResolvedDateStorageForTypeAndProperty(baseType, p.Name)) { case PropertyDateStorage.TwoWayConvertUtc: val = ((DateTime)val).ToUniversalTime(); break; case PropertyDateStorage.TwoWayConvertUtcOnlyWithTime: if (((DateTime)val).TimeOfDay.TotalMilliseconds != 0) { val = ((DateTime)val).ToUniversalTime(); } break; } } } p.Parm.Value = val ?? DBNull.Value; } return(this); }