locked
Petshop 4 architecture pattern question RRS feed

  • Question

  • If someone want to store the database tables in MS Access MDB files. The connection string will contain the physical location of the MDB file by

    Page.Server.MapPath(ConfigurationManager.AppSettings["MdbFileLocation"])

     

    How to pass the parameter from the Web tie to very bottom MdbHelper layer? Or use a abstract factory with parameter? That means all BLL, DLL need to be changed...

    Friday, May 4, 2007 5:50 PM

Answers

  • The data access component handles all interaction with the back end data stores.

    First see this picture explaining the layering and their interactions.

    To add MS Access you need to:

    1.) Create the data access classes for MS Access that implement the IDAL interfaces and compile it into an assembly
    2.) Change the configuration file to point to the new data access classes.

    No changes or recompilations have to be made on the presentation and business components. Microsoft implemented this abstraction using the Factory Design patterns. You can read more about this design patterns in MSDN.

    See this overview of the Pet Shop architecture.

    For more information on the design considerations see Microsoft .NET Pet Shop in MSDN.

    ps: It's pretty sad that we can't use images in our posts.
    Saturday, May 5, 2007 6:48 AM
  • Hi Nick,

    You can, after referencing the System.Web namespace, use HttpContext.Current.Server.MapPath to get the absolute path.
    Sunday, May 6, 2007 9:42 AM

All replies

  • The data access component handles all interaction with the back end data stores.

    First see this picture explaining the layering and their interactions.

    To add MS Access you need to:

    1.) Create the data access classes for MS Access that implement the IDAL interfaces and compile it into an assembly
    2.) Change the configuration file to point to the new data access classes.

    No changes or recompilations have to be made on the presentation and business components. Microsoft implemented this abstraction using the Factory Design patterns. You can read more about this design patterns in MSDN.

    See this overview of the Pet Shop architecture.

    For more information on the design considerations see Microsoft .NET Pet Shop in MSDN.

    ps: It's pretty sad that we can't use images in our posts.
    Saturday, May 5, 2007 6:48 AM
  • Thanks, I read the links before and implemented Access data source following the same architecture structure. However, instead of putting hard code the absolute folder path (for example, c:\xxxx\xxx\xxx\xxx\.....\app_data\db.mdb) of the MDB file into connection string, I want to use

    Page.Server.MapPath("~/app_data/db.mdb")

    to get the absolute from relative path "~/app_data/db.mdb".

    However, Page.Server.MapPath can only be called from presentation tier (Web tier).

    Any good approach to make it available to data access layer?


    Sunday, May 6, 2007 8:02 AM
  • Hi Nick,

    You can, after referencing the System.Web namespace, use HttpContext.Current.Server.MapPath to get the absolute path.
    Sunday, May 6, 2007 9:42 AM