locked
SingleTon Practical usage RRS feed

  • Question

  • User-2054370663 posted

    Hi all,

                  Could you please let me know one practical usage of singleton pattern in asp.net application development. I know the concept but not able to decide on where I should use it. I am looking for some basic examples


    Regards,

    Zamsheer

    Wednesday, December 22, 2010 2:21 AM

Answers

  • User197322208 posted
    for a unit of work, the database connection should be a singleton let's say you want to load all "products" from a table and all "news" to display in the same page. the classes that have to load "products" and "news" requires a connection. If you make the connection a singleton, then you will not open 2 connections.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 22, 2010 3:50 AM

All replies

  • User197322208 posted
    for a unit of work, the database connection should be a singleton let's say you want to load all "products" from a table and all "news" to display in the same page. the classes that have to load "products" and "news" requires a connection. If you make the connection a singleton, then you will not open 2 connections.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 22, 2010 3:50 AM
  • User-2054370663 posted

    Thanks for your reply. But connection to the database is a general example and I have a SQL helper class already for it. Can you please give another example? A high level description is enough. Thanks, Zamsheer

    Thursday, February 3, 2011 1:39 AM
  • User-519136805 posted

    Hi Zamsheer,

    Here is the example you are looking for :

    http://aspalliance.com/810

    Hope this will help !!!


    Thursday, February 3, 2011 5:21 AM