Esempio n. 1
0
        public List <Categorie> GetAll()
        {
            try
            {
                string           sql        = "SELECT C.Id, C.Naam, C.Actief, Count(P.Naam) as Aantal From Categorie as C LEFT JOIN Product as P ON C.Id = P.CategorieId GROUP BY C.Id, C.Naam, C.Actief";
                List <Categorie> categorien = new List <Categorie>();

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                };

                ExecuteSql(sql, parameters);

                DataSet result = ExecuteSql(sql, parameters);

                if (result != null && result.Tables[0].Rows.Count > 0)
                {
                    for (int x = 0; x < result.Tables[0].Rows.Count; x++)
                    {
                        Categorie c = DataSetParser.DataSetToCategorie(result, x);
                        categorien.Add(c);
                    }
                }

                return(categorien);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public List <Categorie> GetAll()
        {
            try
            {
                string           sql           = "SELECT * From Categorie";
                List <Categorie> categorieList = new List <Categorie>();

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                };

                DataSet result = ExecuteSql(sql, parameters);

                if (result != null && result.Tables[0].Rows.Count > 0)
                {
                    for (int x = 0; x < result.Tables[0].Rows.Count; x++)
                    {
                        Categorie c = DataSetParser.DataSetToCategorie(result, x);
                        categorieList.Add(c);
                    }
                }
                return(categorieList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public Categorie GetById(long id)
        {
            try
            {
                string sql = "SELECT * FROM Categorie WHERE CategorieId = @categorieId";

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("categorieId", id.ToString()),
                };

                DataSet   results = ExecuteSql(sql, parameters);
                Categorie c       = DataSetParser.DataSetToCategorie(results, 0);
                return(c);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 4
0
        public Categorie GetById(long id)
        {
            try
            {
                string sql = "SELECT C.Id, C.Naam, C.Actief, Count(P.Naam) as Aantal From Categorie as C INNER JOIN Product as P ON C.Id = P.CategorieId WHERE C.Id = @Id GROUP BY C.Id, C.Naam, C.Actief ";

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("Id", id.ToString()),
                };

                DataSet   results = ExecuteSql(sql, parameters);
                Categorie c       = DataSetParser.DataSetToCategorie(results, 0);
                return(c);
            }
            catch (Exception e)
            {
                throw e;
            }
        }