using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); string query = "SELECT * FROM Properties WHERE PropertyID = @id"; using (SqlCommand command = new SqlCommand(query, connection)) { command.Parameters.Add(new SqlParameter("@id", id)); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { List<string> urlList = !string.IsNullOrEmpty(urls) ? urls.Split(';').ToList() : new List<string>(); return new Property(pId, name, location, price, type, description, urlList, lat, lng); } } } return null; }
public Property GetPropertyDetails(int? id)