In my reading today of Poetics of Biblical Narrative, Meir Sternberg plays with the idea that, in II Samuel 11, David realizes that Uriah knows all about David's affair with Bathsheba. Sternberg also provides reasons for the possibility that Uriah did not know this, and that David recognized that Uriah did not know this. But, in this post, I'll focus more on the scenario in which David knew that Uriah knew, since it's most likely the scenario with which many of us are unfamiliar.
What in II Samuel 11 might indicate that Uriah knew about David's affair with Bathsheba? The text does not say that Uriah did not know, plus there was a messenger going between Bathsheba and David, so Uriah could have found out about the affair. Also, according to Sternberg, Uriah's behavior may be too good to be true. When the king gave Uriah time off to go home, eat, drink, and sleep with Bathsheba, why couldn't Uriah have done that? I mean, it wasn't as if Bathsheba lived too far away from where Uriah was at that moment, in the presence of the king, for David lived close enough to Bathsheba to see her bathing on the roof. Moreover, Uriah may be taunting David. David is giving Uriah permission to eat, drink, and sleep with Bathsheba, but Uriah will not abandon his duties. Uriah may be throwing in David's face the fact that David was eating, drinking, and sleeping with Bathsheba, rather than attending to his duty as the king to lead his people in battle.
But, if David knew that Uriah knew, why would David send Uriah to give Joab the letter that would order Uriah's death? Isn't that having a lot of faith that Uriah would not open the letter and read it? Would David take that risk if he knew that Uriah knew about the affair? According to Sternberg, in this scenario, David was not thinking clearly. After all, David was ordering all of the soldiers to abandon Uriah so he would die, which assumes that the entire army would be privy to information that was denied to Uriah. David was taking quite a gamble that the secret would be kept! In addition, this scenario presumes that enough people knew about David's affair, since even Uriah was aware of it, and so David sent Uriah to his death so he could kill his mocker and take Bathsheba for himself, not so much so that he could cover his tracks.
Perhaps II Samuel 12:12 undermines this scenario, for that passage says that David did this thing secretly. But that may not rule out people---including Uriah---finding out about the secret.