The Lord knows our sin. He actuallly knew it before it happened. The reality is that the Lord loved David knowing that he would sin. So, nothing had changed from the Lord`s perspective. It was simply David`s shock in realizing his own perverseness in committing adultery and murder.