@Mario Formosa Welcome to Microsoft Q&A.
It appears that you are running into execution timeouts while executing and returning large datasets.
By default, the CommandTimeout is set to 30 seconds in the .Net provider. You can override this and set it to 0 to indicate a "no limit".
SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout = 300; //Override cmd.Connection = conn;
However, it is somewhat concerning that you are consuming >40K records in a client WPF application on an S0 database.
Please check the DTU utilization to make sure that you are not hitting the resource limits and getting throttled. You should tune your logic and queries accordingly if this is the case.
You might see all the records getting returned from SSMS because it runs the commands via an SQL provider (without the constraints of timeouts etc.) and doesn't have to go through various layers (application logic, business logic etc.) in a typical client application.
Please let us know if you have any further questions.
If an answer is helpful, please "Accept answer" or "Up-Vote" for the same which might be beneficial to other community members reading this thread.