Esempio n. 1
0
        public void ConvertDataSetToDict()
        {
            DateTime     now        = DateTime.Now;
            DateTime     secondDate = now.AddDays(1);
            const string tableName  = "MyTable";
            DataTable    dt1        = CreateTable(tableName + "1", now, secondDate);
            DataTable    dt2        = CreateTable(tableName + "2", now, secondDate);
            DataSet      ds         = new DataSet();

            ds.Tables.Add(dt1);
            ds.Tables.Add(dt2);

            c.Dict   dict         = ds.ToDict();
            string[] columnNames  = (string[])dict.x;
            object[] columnValues = (object[])dict.y;

            Assert.AreEqual(2, columnNames.Length);
            Assert.AreEqual(2, columnValues.Length);

            Assert.AreEqual(tableName + "1", columnNames[0]);
            Assert.AreEqual(tableName + "2", columnNames[1]);

            c.Dict    d1            = ((c.Dict[])columnValues[0])[0];
            DataTable tableToCheck1 = d1.ToDataTable(tableName);

            CheckDataTable(now, secondDate, tableToCheck1, tableName);

            c.Dict    d2            = ((c.Dict[])columnValues[1])[0];
            DataTable tableToCheck2 = d2.ToDataTable(tableName);

            CheckDataTable(now, secondDate, tableToCheck2, tableName);
        }
Esempio n. 2
0
        public void ConvertSimpleDictToDataTableTest()
        {
            DateTime     firstDate  = DateTime.Now;
            DateTime     secondDate = firstDate.AddDays(1);
            const string tableName  = "MyTable";

            c.Dict    dict = CreateDict(firstDate, secondDate);
            DataTable dt   = dict.ToDataTable(tableName);

            CheckDataTable(firstDate, secondDate, dt, tableName);
        }
Esempio n. 3
0
        public void ConvertSimpleDataTableToDict()
        {
            DateTime     now        = DateTime.Now;
            DateTime     secondDate = now.AddDays(1);
            const string tableName  = "MyTable";
            DataTable    dt         = CreateTable(tableName, now, secondDate);

            c.Dict dict = dt.ToDict();

            DataTable tableToCheck = dict.ToDataTable(tableName);

            CheckDataTable(now, secondDate, tableToCheck, tableName);
        }
Esempio n. 4
0
        /// <summary>
        /// Converts the graph of c.Dict into DataSet
        /// </summary>
        /// <param name="dict">The dict.</param>
        /// <returns></returns>
        public static DataSet ToDataSet(this c.Dict dict)
        {
            Guard.ThrowIfNull(dict, "dict");

            string[] tableNames = (string[])dict.x;
            object[] dicts      = (object[])dict.y;

            DataSet ds = new DataSet();

            int tableCount = tableNames.Length;

            if (tableCount == 0)
            {
                return(ds);
            }

            for (int i = 0; i < tableCount; i++)
            {
                c.Dict tableDict = (c.Dict)((Array)dicts[i]).GetValue(0);
                ds.Tables.Add(tableDict.ToDataTable(tableNames[i]));
            }

            return(ds);
        }