public void CreateGeographyInsertCommandTest() { DataColumn dc1 = new DataColumn("ID", typeof(int)); DataColumn dc2 = new DataColumn("GEOG", typeof(SqlGeography)); DataColumn dc3 = new DataColumn("Name", typeof(string)); List <DataColumn> list = new List <DataColumn>() { dc1, dc2, dc3 }; ICoordinate[] coords = new List <Coordinate>() { new Coordinate(90, -90), new Coordinate(-90, 90), new Coordinate(180, -90), new Coordinate(90, -90) }.ToArray(); MemPolygonFeature feature = new MemPolygonFeature(new LinearRing(coords), null); feature.Attributes.SetValue("ID", 123); feature.Attributes.SetValue("Name", "Vish"); SqlCommand sqlCommand = SQLUtilities.CreateGeographyInsertCommand("GeographyTable", "SHAPE", list.GetEnumerator(), feature); Assert.IsNotNull(sqlCommand, "Failed to generate INSERT geography command SQL."); Assert.AreEqual(sqlCommand.Parameters.Count, 4, "INSERT SQL parameter count does not match"); dc1.AutoIncrement = true; sqlCommand = SQLUtilities.CreateGeographyInsertCommand("GeographyTable", "SHAPE", list.GetEnumerator(), feature); Assert.IsNotNull(sqlCommand, "Failed to generate INSERT geography command SQL."); Assert.AreEqual(sqlCommand.Parameters.Count, 3, "INSERT SQL with auto increment column parameter count does not match"); }
public void Add(IGISFeature feature) { IDbCommand dbCommand = GetDBCommand(); SqlCommand sqlCommand = SQLUtilities.CreateGeographyInsertCommand(_tableName, GetShapeFieldName(), _gisFields, feature); sqlCommand.Connection = dbCommand.Connection as SqlConnection; sqlCommand.ExecuteNonQuery(); }
public void Add(IGISFeature feature) { IDbCommand dbCommand = GetDBCommand(); SqlCommand sqlCommand = SQLUtilities.CreateGeographyInsertCommand(GetTableName(), GetShapeFieldName(), GetGISFields().GetEnumerator(), feature); sqlCommand.Connection = dbCommand.Connection as SqlConnection; sqlCommand.ExecuteNonQuery(); }