In 2 Samuel 7 verse 18 and on, David prays to God. He made a request of God, but his request was not his idea, it was based on what God had already told him.
In verse 26 he asked that his house would be established before God. David had already been promised by God through Nathan the prophet that his house would be established forever ( verse 16), meaning that his family would continue forever. David prayed according to what God had promised him, according to God’s revealed will.
The result. His prayer was answered and God was magnified according to the desire David expressed in verse 26. Jesus was a descendant of David, through whom the church was born. Thus the church is the spiritual descendant of David, and through the church David’s family lives on forever, and it is a family that supremely magnifies, brings glory to God.
Like David, when we pray according to God’s promises, His will, our prayers will be answered and God will be magnified.
Romans 8: 26 & 27 say:
26 Likewise the Spirit also helps in our weaknesses. For we do not know what we should pray for as we ought, but the Spirit Himself makes intercession for us with groanings which cannot be uttered. 27 Now He who searches the hearts knows what the mind of the Spirit is, because He makes intercession for the saints according to the will of God.
We don’t know what we should pray for, how to pray, but the Holy Spirit intercedes for us and through us according to the will of God.
This should always be our goal in prayer. God the Spirit in us praying to God the Father and Jesus the Son and therefore like David praying according to the will of God, according to His promises.
That kind of prayer will always be answered and magnify God.