by dan
21. May 2009 20:29
Some days ago my director asked me to transfer some data from an excel file to an existing SQL database. Beeing an AxConsultant I tend to use the CMS persistence framework to accomplish such a task. That gave me the idea for this post series: I will try to give a brief outline on the CMS persistence framework and how to use it.
Part one will deal with the subject of direct database queries:
The CMS Persistence Framework
When you tend to use the CMS persistence framework inside your own projects you need to reference the Axinom.Framework.dll1 that can be found inside the components subfolder of the AxCMS.net Premium Template Project or the AxCMS.net Standard Template Project.
The Axinom.Framework.dll defines all relevant framework components inside the Axinom.Framework.Data namespace. Therefore every class using the CMS persistence framework needs to use this namespace:
1: using Axinom.Framework.Data;
1Naturally you need to ask Axinom first if you are allowed to use the CMS persistence framework particularly if it is a productive customer project :).
The Connection Manager Object
To connect to a database you need a connection manager that handles the database connection first. Inside AxCMS.net projects all that is done in the background. Inside your own projects you need to handle the connection manager by yourself:
1: ConnectionManager manager = new ConnectionManager(
2: new SqlDbFactory(),
3: "Data Source=(local);Initial Catalog=AxCMS_PremiumSample;Integrated Security=True");