And it is written (1 Samuel 2): "And Eli blessed Elkanah and his wife, etc." He said to him: All the children that the Holy One, blessed be He, is destined to give you—may they be from this righteous woman. And similarly: "And Isaac entreated the LORD opposite his wife" (Genesis 25:21). What is the meaning of "opposite his wife"? This teaches that Isaac was stretched out [in prayer] here, and she was stretched out [in prayer] there. He said before Him: Master of all the worlds, all the children that You are destined to give me—may they be from this righteous woman. She too said: All the children that You are destined to give me—may they be from this righteous man. And similarly: "And may your house be like the house of Perez, etc." (Ruth 4:12). They said to him: All the children that the Holy One, blessed be He, is destined to give you—may they be from this righteous woman.
Eli, Isaac, and Boaz Blessed That Children Come From the Righteous Spouse
Midrash Shmuel 6:3
וכתיב (שמואל א' ב') וברך עלי את אלקנה ואת אשתו וגו', (אמרו) [אמר] לו כל בנים שהקדוש ברוך הוא עתיד ליתן לך, יהיו מן הצדקת הזו, ודכותה ויעתר יצחק לה' לנכח אשתו (בראשית כ"ה כ"א), מהו לנכח אשתו, מלמד שהיה יצחק שטוח כאן והיא שטוחה כאן, אמר לפניו רבון כל העולמים כל בנים שאתה עתיד ליתן לי יהיו מן הצדקת הזו, אף היא אמרה כל בנים שאתה עתיד ליתן לי יהיו מן הצדיק הזה ודכותה ויהי ביתך כבית פרץ וגו', (רות ד' י"ב), אמרו לו כל בנים שהקדוש ברוך הוא עתיד ליתן לך יהיו מן הצדקת הזו.