SQL Server 2008中的地理空间类型是什么ADO类型?

| 我希望重构此方法(来自Rob Conery的Massive.cs):
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;
        }
        //from DataChomp
        if (item.GetType() == typeof(string))
            p.Size = 4000;
    }
    cmd.Parameters.Add(p);
}
可能添加对Geographic类型的检查将解决ExecuteNonQuery和空间数据类型的问题,但是我将检查哪种类型?
if (item.GetType() == typeof(//WhatType?//)) {}
    
已邀请:
我相信SqlGeography是您要寻找的。     
这个怎么样?
if (item.GetType() == typeof(Microsoft.SqlServer.Types.SqlGeography)) 
{
     SqlParameter p = new SqlParameter();
     p.SqlDbType = System.Data.SqlDbType.Udt;
     p.UdtTypeName = \"geography\";
     p.Value = value;
}
    

要回复问题请先登录注册