With the PersistentTableArray class of the non-commercial .net library finaquant® protos you can read and write in-memory tables from/to a relational database together with their instance information.
If you have already installed Microsoft Visual Studio C# 2010 Express or a higher version on your computer it is quite easy to get started with persistent table arrays. The installation file of Visual Studio is packed with a free database SQL Server Express you don’t need to install a database software separately.
You will need Visual Studio in any case to run the demo function for persistent table arrays in the Visual Studio project file FinaquantProtosStarter which you can download at the product page of finaquant® protos.
Initiating a persistent table array is about setting the correct database connection string and data provider to a DataStore object:
using FinaquantProtos; using System.Data.SqlClient; // initiate DataStore for database connection DataStore datstore = new DataStore(Provider: "System.Data.SqlClient"); // open database connection string ConnStr = “@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Tuncali\Documents\finaquant.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" datstore.OpenConnection(ConnStr); // initiate a persistent table array var PTblCost = new PersistentTableArray(TableName: "costs", dstore: datstore);
The software ingredients you need for the test
- A computer with a Windows operating system and .Net 4.0 framework (client version)
- Finaquant Protos .net library (release 1.04 or higher)
- Microsoft Visual Studio C# (2010 Express or higher versions) that comes with an MS SQL Server Express database
- Visual Studio project file FinaquantProtosStarter with the related demo function
Following steps explain all the preparations required for running the related demo function in FinaquantProtosStarter.
1) Install Microsoft Visual Studio C# 2010 Express(which is free) or a higher version.
For downloads visit: Microsoft Visual Studio
Select “install with a database” if you are given the option.
2) Download and install the latest release of finaquant® protos.
3) Download and unzip the MS Visual Studio file FinaquantProtosStarter (1185 downloads)
You need to be registered and logged in at finaquant.com in in order to download this file.
4) Open FinaquantProtosStarter solution file (with Visual Studio) and create a new database named finaquant.
See detail steps for help
B) Select Database Explorer from the menu “View>Other Windows” to create a new database
Persistent Table Array needs an initially empty and dedicated database.
The menu path can be slightly different in 2012 versions of Visual Studio, like:
View>Other Windows>Data Sources, or View>SQL Server Object Explorer
C) Press icon Connect to Database and …
… enter the name of the new database (finaquant) in the opening window. Then press OK without making any other changes.
Confirm the next window asking whether the database should be created with OK.
New database named finaquant is created:
5) Set the database connection string in the demo function
Persistent_Table_Array()in code file Demo.cs and run the method which calculates price tables for given instances of cost and margin tables. See detail steps for help
public static void Persistent_Table_Array()in code file Demo.cs
B) In order to get the connection string right-click on the database and select properties.
C) In the properties window right-click on the field value for connection string, and select Select All, press Control-C to store the connection string to clipboard.
D) Paste the connection string in the demo function as updated string value for
ConnStr1, and save code file Demo.cs
E) Out-comment all other demo functions, un-comment
DemoFunctions.Persistent_Table_Array() in the code file Program.cs and press F5 to run the demo function.
This demo function should calculate and display price tables for each instance (country and year) of cost and margin tables.
The table named
list_of_data_tables has an entry for each instance of data tables.