I am going back and forth with this changing my design multiple times.
I have Two classes Shop & Source,
each Shop has IList<Product> (approx. 1000 products),
and Source has IList<Item> (approx 200),
All Classes needs to perform some actions on the same Database.
At first, I shared an open DbConnection with all objects:
And when building my WebService it became problematic,
I cached the open static DbConnection (bad as it sounds) and used it.
but it started making trouble when testing multiple requests, when the connection closed sporadically and ExecuteReader() threw (wasn't using MARS).
After reading This and many other sources suggesting to rely on connection pooling.
I replaced my code to open a connection just before I query, and dispose of it when finished.
but I notice a degredation in performance.
Can I check how the pool is functioning (or isn't it?)
Question: How can I monitor my SqlConnection pool?
Question: Is there any other design to share this connection between these many objects.
Thanks a lot.