コード例 #1
0
        public IList <Apartment> GetAllApartmentByLocation(string location)
        {
            string sqlstring = $"Select * from dbo.apartment like location = {location}";

            using (SqlConnection sqlConnection = new SqlConnection(GetConnectionString()))
            {
                sqlConnection.Open();
                using (var sqlcommand = new SqlCommand(sqlstring, sqlConnection))
                {
                    using (var reader = sqlcommand.ExecuteReader())
                    {
                        List <Apartment> liste = new List <Apartment>();
                        while (reader.Read())
                        {
                            Apartment _apartment = ReadApartment(reader);
                            liste.Add(_apartment);
                        }
                        return(liste);
                    }
                }
            }
        }
コード例 #2
0
        public IList <Apartment> GetApartmentByPostalCode(string PostalCode)
        {
            string sqlstring = $"Select * from dbo.Apartment where postalcode = {PostalCode}";

            using (SqlConnection sqlConnection = new SqlConnection(GetConnectionString()))
            {
                sqlConnection.Open();
                using (var sqlcommand = new SqlCommand(sqlstring, sqlConnection))
                {
                    using (var reader = sqlcommand.ExecuteReader())
                    {
                        List <Apartment> liste = new List <Apartment>();
                        while (reader.Read())
                        {
                            Apartment _Apparment = ReadApartment(reader);
                            liste.Add(_Apparment);
                        }
                        return(liste);
                    }
                }
            }
        }