Пример #1
0
 public Neighborhood[] GetIntersectingNeighborhoods(double latitude, double longitude)
 {
     List<Neighborhood> neighborhoods = new List<Neighborhood>();
     string sql = string.Format( @"
             DECLARE @geog GEOGRAPHY
             SET @geog = 'POINT({0} {1})'
             select * from Neighborhood
             where Geo.STIntersects(@geog)=1
         ", latitude, longitude);
     using(SqlConnection conn = new SqlConnection(Configuration.ConnectionString))
     using(SqlCommand cmd = new SqlCommand(sql, conn)){
         conn.Open();
         SqlDataReader reader = cmd.ExecuteReader();
         while(reader.Read()) {
             var hood = new Neighborhood();
             hood.Id = (Guid)reader["Id"];
             hood.Name = (String)reader["Name"];
             hood.KML = (String)reader["KML"];
             hood.PrimaryContactId = (Guid) reader["PrimaryContactId"];
             neighborhoods.Add(hood);
         }
     }
     return neighborhoods.ToArray();
 }
Пример #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Neighborhoods EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNeighborhoods(Neighborhood neighborhood)
 {
     base.AddObject("Neighborhoods", neighborhood);
 }
Пример #3
0
 /// <summary>
 /// Create a new Neighborhood object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="primaryContactId">Initial value of the PrimaryContactId property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
 public static Neighborhood CreateNeighborhood(global::System.Guid id, global::System.Guid primaryContactId, global::System.DateTime createdDate, global::System.DateTime modifiedDate)
 {
     Neighborhood neighborhood = new Neighborhood();
     neighborhood.Id = id;
     neighborhood.PrimaryContactId = primaryContactId;
     neighborhood.CreatedDate = createdDate;
     neighborhood.ModifiedDate = modifiedDate;
     return neighborhood;
 }