private Dictionary <int, Geometry> GetGeometries <T>(string sql) where T : ActiveBaseEntity <T>, IIdentifiable { var ds = SqlActions.ExecuteDataSet(sql, true); var geometries = new Dictionary <int, Geometry>(); WKBReader reader = new WKBReader(); foreach (DataRow dr in ds.Tables[0].Rows) { var bytes = dr[1] as byte[]; var trimmed = new byte[bytes.Length - 4]; Array.Copy(bytes, 4, trimmed, 0, trimmed.Length); geometries.Add((int)dr[0], (Geometry)reader.Read(trimmed)); } return(geometries); /* * using (var rows = SqlActions.ExecuteReader(sql, true)) * { * var geometries = new Dictionary<int, Geometry>(); * * WKBReader reader = new WKBReader(); * while (rows.Read()) * { * var bytes = rows.GetValue(1) as byte[]; * var trimmed = new byte[bytes.Length - 4]; * Array.Copy(bytes, 4, trimmed, 0, trimmed.Length); * * geometries.Add(rows.GetInt32(0), (Geometry)reader.Read(trimmed)); * } * return geometries; * }*/ }
public NHibernateSession(ISession wrap, IStatelessSession wrapStateless) { _wrap = wrap; _sessionSqlActions = new SqlActions(this); _wrapStateless = wrapStateless; if (_wrapStateless != null) { _isStateless = true; } }
/// <summary> /// Trae los datos de campos Point de mysql tipados como ídem en un diccionario. /// </summary> /// <typeparam name="T">El tipo a consultar.</typeparam> /// <param name="whereField">El campo para hacer el where.</param> /// <param name="whereValue">El valor del where.</param> /// <param name="selectField">Opcional. El campo a consultar. Si no se pasa el parámetro trae el campo tipo Point de la tabla, si es que hay uno.</param> /// <returns>Diccionario con ids y Points de NetTopology.</returns> private Dictionary <int, Point> GetPoints <T>(string sql) where T : ActiveBaseEntity <T>, IIdentifiable { using (var rows = SqlActions.ExecuteReader(sql, true)) { var points = new Dictionary <int, Point>(); WKBReader reader = new WKBReader(); while (rows.Read()) { var bytes = rows.GetValue(1) as byte[]; var trimmed = new byte[bytes.Length - 4]; Array.Copy(bytes, 4, trimmed, 0, trimmed.Length); points.Add(rows.GetInt32(0), (Point)reader.Read(trimmed)); } return(points); } }
public void Ping() { SqlActions.ExecuteNonQuery("select 1"); }