Exemplo n.º 1
0
        public IEnumerable <DAplikacija> GetData(string query, int pageIndex, int pageSize, string sortKey, string asceding)
        {
            try
            {
                List <DAplikacija> result = new List <DAplikacija>();

                SQLiteConnection connection = new SQLiteConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);

                using (connection)
                {
                    connection.Open();
                    SQLiteCommand cmd;
                    using (cmd = new SQLiteCommand(this.GetSQL(sortKey, asceding), connection))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@searchParam", "%" + query + "%");
                        //cmd.Parameters.AddWithValue("@pageSize", pageSize);
                        //cmd.Parameters.AddWithValue("@pageIndex", pageIndex);

                        SQLiteDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                result.Add(ReflectPropertyInfo.ReflectType <DAplikacija>(reader));
                            }
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                //connection.Close(); //tega ne rabimo če uporabimo using
            }
        }
Exemplo n.º 2
0
        public static IEnumerable <DSifranti> GetSifranti(string id)
        {
            try
            {
                List <DSifranti> result = new List <DSifranti>();

                SQLiteConnection connection = new SQLiteConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);

                using (connection)
                {
                    connection.Open();
                    SQLiteCommand cmd;
                    using (cmd = new SQLiteCommand("Select * from Sifranti where id = @id", connection))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", id);

                        SQLiteDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                result.Add(ReflectPropertyInfo.ReflectType <DSifranti>(reader));
                            }
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                //connection.Close(); //tega ne rabimo če uporabimo using
            }
        }