Esempio n. 1
0
        public List <IDomenskiObjekat> Pretrazi(IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand("", connection, transaction);

            command.CommandText = $"{objekat.Get} {objekat.FullTable} {objekat.Join} {objekat.SearchWhere(objekat.Kriterijum)} {objekat.GroupBy}";
            SqlDataReader reader = command.ExecuteReader();

            return(objekat.GetReaderResult(reader));
        }
Esempio n. 2
0
        public List <IDomenskiObjekat> vratiBez(IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand("", connection, transaction);

            command.CommandText = $"{objekat.Get} {objekat.Table} {objekat.Join}";
            SqlDataReader reader = command.ExecuteReader();

            return(objekat.GetReaderResult(reader));
        }
Esempio n. 3
0
        public List <IDomenskiObjekat> VratiSvePoKriterijumu(IDomenskiObjekat objekat, Automobil automobil)
        {
            SqlCommand command = new SqlCommand("", connection);

            command.CommandText = $"{objekat.Get} {objekat.FullTable} {objekat.SearchWhere(automobil.AutomobilID.ToString())}";
            SqlDataReader reader = command.ExecuteReader();

            return(objekat.GetReaderResult(reader));
        }
Esempio n. 4
0
        public List <IDomenskiObjekat> Search(string criteria, IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand();

            command.Transaction = transaction;
            command.Connection  = connection;
            command.CommandText = $"select * from {objekat.Table} {objekat.Join} {objekat.SearchWhere(criteria)}";
            SqlDataReader reader = command.ExecuteReader();

            return(objekat.GetReaderResult(reader));
        }
Esempio n. 5
0
        public List <IDomenskiObjekat> Login(IDomenskiObjekat objekat)
        {
            Radnik     radnik  = (Radnik)objekat;
            SqlCommand command = new SqlCommand("", connection);

            command.CommandText = $"{objekat.Get} {objekat.Table} " +
                                  $"{objekat.SearchWhere(radnik.KorisnickoIme, radnik.Sifra)} ";
            SqlDataReader reader = command.ExecuteReader();

            return(objekat.GetReaderResult(reader));
        }
        public List <IDomenskiObjekat> SearchJoin(string criteria, IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand();

            command.Transaction = transaction;
            command.Connection  = connection;
            command.CommandText = $"select distinct {objekat.SearchColumns} from {objekat.Table} {objekat.Join} {criteria}";
            SqlDataReader reader = command.ExecuteReader();

            List <IDomenskiObjekat> result = objekat.GetReaderResult(reader);

            reader.Close();

            return(result);
        }
        public List <IDomenskiObjekat> VratiSve(IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand();

            command.Transaction = transaction;
            command.Connection  = connection;
            command.CommandText = $"select * from {objekat.Table} {objekat.Join}";
            SqlDataReader reader = command.ExecuteReader();

            List <IDomenskiObjekat> result = objekat.GetReaderResult(reader);

            reader.Close();

            return(result);
        }
        public IDomenskiObjekat SearchSlozeniObjekat(string criteria, IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand();

            command.Transaction = transaction;
            command.Connection  = connection;
            command.CommandText = $"select distinct {objekat.SearchColumns} from {objekat.Table} {objekat.Join} {criteria}";
            SqlDataReader reader = command.ExecuteReader();

            List <IDomenskiObjekat> result = objekat.GetReaderResult(reader);

            reader.Close();

            if (result.Count != 1)
            {
                throw new Exception("Razlicito od jednog sloga!!!!");
            }

            foreach (var item in objekat.WeakObjects)
            {
                IDomenskiObjekat weakObject = item[0];

                List <IDomenskiObjekat> weakObjectList = SearchMod($"where {weakObject.DependentObjectID} = {objekat.ColumnId}", weakObject);

                result[0].FillWeakObjects(weakObjectList);
            }

            foreach (var item in objekat.AssociativeObjects)
            {
                IDomenskiObjekat associativeObject = item[0];

                List <IDomenskiObjekat> associativeObjectList = SearchJoin(criteria, associativeObject);

                result[0].FillAssociativeObjects(associativeObjectList);
            }



            return(result[0]);
        }
        public IDomenskiObjekat SearchById(IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand();

            command.Transaction = transaction;
            command.Connection  = connection;
            command.CommandText = $"select * from {objekat.Table} WHERE {objekat.SearchById()}";
            SqlDataReader reader = command.ExecuteReader();

            List <IDomenskiObjekat> result = objekat.GetReaderResult(reader);

            if (result.Count > 1)
            {
                throw new Exception("Object is not unique");
            }
            if (result.Count == 0)
            {
                return(null);
            }

            reader.Close();

            return(result[0]);
        }