Custom Data Access

Znode uses NetTiers data access layer which is automatically generated using the NetTiers Codesmith template. This layer includes strongly typed data access libraries for all tables in the Znode Storefront database.

There may be times however when you need to add your own custom data access library. You can do this by adding your custom data access class to the ZNode.Libraries.DataAccess.Custom library.

Note: Any changes to the existing database schema can break the existing NetTiers data access layer. If you are changing the existing schema you should re-generate the NetTiers layer.

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;
}

Comments

rcoker08's picture

Customizing NetTiers Code

I need to change NetTiers code.

1. Can I do this from some ZNode tool or do I need to purchase NetTiers software ?
2. If yes (buy NetTiers), are there instructions on doing this once, I get the software ?

I am guessing that if I want to restructure a table, say ZNodeProduct, I need to do the following:

a) Restructure table in SQL Server.
b) Change stored procedures related to product.
c) Run NetTiers. This should generate the following all product 'generated' files in:
i) Generate ZNode.Libraries.DataAccess.Bases
ii) Generate ZNode.Libraries.DataAccess.Data.SqlClient
iii) Generate ZNode.Libraries.DataAccess.Entities
iv) Generate ZNode.Libraries.DataAccess.Service
Does it generate IProduct interface class in ZNode.Libraries.DataAccess.Entities ?
d) Change admin ASPX pages.