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]);
        }
        public int UpdateObject(IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand();

            command.Transaction = transaction;
            command.Connection  = connection;
            command.CommandText = $"update {objekat.Table} set {objekat.UpdateValues} where {objekat.SearchById()}";
            return(command.ExecuteNonQuery());
        }
        public int UpdateSlozeniObjekat(IDomenskiObjekat objekat)
        {
            SqlCommand command = new SqlCommand();

            command.Transaction = transaction;
            command.Connection  = connection;
            command.CommandText = $"update {objekat.Table} set {objekat.UpdateValues} where {objekat.SearchById()}";
            int rows = command.ExecuteNonQuery();

            foreach (var item in objekat.WeakObjects)
            {
                if (item.Count > 0)
                {
                    DeleteObjects(item[0].Table, $"{item[0].DependentObjectID} = {objekat.ColumnId}");
                    foreach (var insertItem in item)
                    {
                        Insert(insertItem);
                    }
                }
            }

            foreach (var item in objekat.AssociativeObjects)
            {
                if (item.Count > 0)
                {
                    DeleteObjects(item[0].Table, $"{objekat.SearchId} = {objekat.ColumnId}");
                    foreach (var insertItem in item)
                    {
                        Insert(insertItem);
                    }
                }
            }

            return(rows);
        }