Exemple #1
0
        // Kreira listu objekata èitanjem podataka iz baze
        public static ArtiklList CreateNew(IDataReader dr)
        {
            ArtiklList rez = new ArtiklList();

            while (dr.Read())
            {
                rez.Add(Artikl.CreateNew(dr));
            }
            return(rez);
        }
Exemple #2
0
        // Dohvat artikala po razlièitim kriterijima

        public ArtiklList FetchAll()
        {
            using (SqlConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                using (SqlCommand cmd = db.CreateCommand())
                {
                    cmd.CommandText = "[dbo].[ap_ArtiklList_R]";
                    cmd.CommandType = CommandType.StoredProcedure;

                    db.Open();
                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        return(ArtiklList.CreateNew(dr));
                    }
                }
            }
        }