Example #1
0
        public ATable cacheTable(string tablename)
        {
            // if (this._tableArray.ContainsKey(tablename)) this._tableArray.Remove(tablename);
            // Query the database to get information about this table.
            ATable newCacheObject = null;
            System.Diagnostics.Debug.WriteLine("Caching Table: " + tablename);
            try
            {
                ATable cacheObject = new ATable(tablename);
                FieldDescriptor[] fieldinfo = this._db.GetDatabaseProvider().getTableDescription(tablename);
                if (fieldinfo == null)
                {
                    throw (new Exception("Error getting table."));
                }

            foreach (FieldDescriptor fInfo in fieldinfo)
            {
                cacheObject.addField(fInfo.name, fInfo.type, fInfo.maxlen, fInfo.defaultval, fInfo.modifiers);
            }
            this._tableArray.Add(tablename, cacheObject);
            newCacheObject = cacheObject;
            }
            catch(Exception e)
            {
                System.Diagnostics.Debug.Print(e.Message);
            }
            return newCacheObject;
        }
Example #2
0
        public System.Collections.ArrayList getResultAsFieldArrayWithCaching()
        {
            System.Collections.ArrayList retArray = new System.Collections.ArrayList();
            this.Execute();
            TableDataReader tdr = this.getDatabaseObject().CreateTableDataReader();
            tdr.Bind(this);
            while (tdr.Read())
            {
                if (tdr.getFieldList().Count > 1)
                {
                    //System.Collections.ArrayList retArray2 = new System.Collections.ArrayList();
                    ATable coll = new ATable();

                    foreach (AField a in tdr.getFieldList())
                    {
                        if (this.getField(a.name) != null)
                        {
                            AField newField = coll.addField(a.name, ABSTRACTDATATYPES.AString);
                            newField.value = a.value;
                        }
                    }
                    retArray.Add(coll);
                }
                else
                    retArray.Add(Convert.ToString(((AField)tdr.getFieldList()[0]).value));
            }

            return retArray;
        }
Example #3
0
        public ATable getTableObject(string name)
        {
            // check the cache...
            if (this.GetTableCache().getCachedTable(name) != null) return this.GetTableCache().getCachedTable(name);

            // Query the database to get information about this table.
            ATable tblObject = new ATable(name);

            FieldDescriptor[] fieldinfo = this.GetDatabaseProvider().getTableDescription(name);
            if (fieldinfo == null) return null;
            foreach (FieldDescriptor fInfo in fieldinfo)
            {
                tblObject.addField(fInfo.name, fInfo.type, fInfo.maxlen, fInfo.modifiers);
            }
            return tblObject;
        }