Exemple #1
0
        /// <summary>
        /// Gets all data table rows.
        /// </summary>
        /// <typeparam name="T">The type definition of data table row.</typeparam>
        /// <returns>The object array of type definition.</returns>
        public T[] GetAllDataTableRows <T>() where T : DataTableRow, new()
        {
            DataTableAddressMap addressMap = GetDatabaseAddressMap <T>();
            BoxDBAdapter        dbAdapter  = GetDatabaseBoxAdapter(addressMap);
            List <T>            results    = new List <T>();

            if (dbAdapter != null)
            {
                try
                {
                    string tableName = addressMap.Type;
                    dbAdapter.EnsureTable <T>(tableName, addressMap.PrimaryPropertyName);
                    dbAdapter.Open();
                    results = dbAdapter.SelectAll <T>(tableName);
                }
                catch (Exception exception)
                {
                    Debug.LogException(exception);
                }
                finally
                {
                    dbAdapter.Dispose();
                }
            }

            return(results.ToArray());
        }
        public void SelectAllTest()
        {
            BoxDBAdapter db = GetBoxDBAdapter();
            List <BoxDBAdapterTestVO> list = db.SelectAll <BoxDBAdapterTestVO>(tableName);

            foreach (BoxDBAdapterTestVO vo in list)
            {
                Debug.Log(vo.ToString());
            }

            db.Dispose();
            Assert.AreEqual(3, list.Count);
        }