I am looking for a refactoring of this method (from Massive.cs from Rob Conieri ):
public static void AddParam(this DbCommand cmd, object item) { var p = cmd.CreateParameter(); p.ParameterName = string.Format("@{0}", cmd.Parameters.Count); if (item == null) { p.Value = DBNull.Value; } else { if (item.GetType() == typeof(Guid)) { p.Value = item.ToString(); p.DbType = DbType.String; p.Size = 4000; } else if (item.GetType() == typeof(ExpandoObject)) { var d = (IDictionary<string, object>)item; p.Value = d.Values.FirstOrDefault(); } else { p.Value = item; }
Adding a geography type check is likely to fix my problem with ExecuteNonQuery types and spatial data, but what type should I check?
if (item.GetType() == typeof(//WhatType?//)) {}
source share