|
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
The Znode DAL
View of the Znode DAL Libraries
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:
|