Data Access Layer (DAL)

Znode Storefront uses a multi-tier DAL (Data Access Layer). This layer exposes strongly typed DataSets that make it easier and more efficient to pass entities between the business logic layer and the DAL. You can either modify the DAL libraries by hand or use CodeSmith templates included with the storefront to re-generate them based on the database schema.

Please Note

Catalog and Customer Data is stored in a SQL Server 2005 database
Data is accessed using stored procedures. Znode Storefront does not use dynamic SQL queries except for certain search functionality
Znode Storefront uses XML Serialization extensively to retrieve object oriented data from the database. This reduces the number of calls back and forth from the database

The Znode DAL

The Znode DAL includes 5 different C# libraries that can be modified independently
The ZNode.Libraries.DataAccess.Entities library defines the strongly typed DataSets. For example: The Order Entity maps all the fields from the ZNodeOrder table to properties in the DataSet
The ZNode.Libraries.DataAccess.Service library defines methods to retrieve data from the SQL Server database. The service methods return strongly typed DataSets (Entity objects)
The ZNode.Libraries.DataAccess.Custom library enables developers to add their own custom data access methods. For example, if you needed to create a new table in the database and access data from it, you would add your data retrieval functions here

View of the Znode DAL Libraries

DAL

Example of a native data access method using the Znode DAL:

 

public TList<Manufacturer> GetAllByPortalID(int _portalID)

{

  ZNode.Libraries.DataAccess.Service.ManufacturerService _manufacturerAccess 

               = new ManufacturerService();

  TList<ZNode.Libraries.DataAccess.Entities.Manufacturer> _ManufacturerList 

               = _manufacturerAccess.GetByPortalID(_portalID);

 

  return _ManufacturerList;

}

Example of a custom data access method:

 

public DataSet GetDashboardItemsByPortal(int PortalID)

{

    // Create Instance of Connection  Object

   string ConnectionString = 

               System.Configuration.ConfigurationManager.ConnectionStrings["ZNodeECommerceDB"].ConnectionString;

   SqlConnection MyConnection = new SqlConnection(ConnectionString);

 

   //Create Instance of Adapter  Object

   SqlDataAdapter MyDataAdapter = new SqlDataAdapter("ZNODE_GetDashboardItemsByPortal", MyConnection);

 

   //Mark as stored procedure

   MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;

 

   // Add Parameters to Stored Procedure

   SqlParameter myParam = new SqlParameter("@PortalID", SqlDbType.Int);

   myParam.Value = PortalID;

 

   MyDataAdapter.SelectCommand.Parameters.Add(myParam);

 

   //Fill DataSet 

   DataSet MyDataSet = new DataSet();

   MyDataAdapter.Fill(MyDataSet);

 

  //Return DataSet

  return MyDataSet;

}

 


See Also:

Overview

Business Logic Layer (BLL)