public DataEvent SelectByBossID(long id)
        {
            string    cmdText = string.Format("select * from {0} where bossid = {1}", Name, id);
            DataEvent ev      = CreateDataEvent();

            using (DataCommandBase dtc = new LongDataCommand(string.Format("select id from {0} where bossid = {1}", Name, id)))
            {
                _file.AddCommand(dtc);
                dtc.Wait();
                ev.ID = (long)dtc.Result;
            }
            using (DataCommandBase dtc = new EventDataCommand(ev, cmdText))
            {
                _file.AddCommand(dtc);
                dtc.Wait();
            }
            foreach (DataTableBase linkedTable in LinkedTables)
            {
                long[] linkids = linkedTable.SelectIDsByIndexColumn(id);
                if (linkids != null)
                {
                    foreach (long linkid in linkids)
                    {
                        ev.LinkedDataEvents(linkedTable).Add(linkedTable.SelectByID(linkid));
                    }
                }
            }
            return(ev);
        }
        public bool DoesBossIDExist(long id)
        {
            bool   ret;
            long   count   = 0;
            string cmdText = string.Format("select COUNT(*) from {0} where bossid = {1}", Name, id);

            using (DataCommandBase dtc = new LongDataCommand(cmdText))
            {
                _file.AddCommand(dtc);
                dtc.Wait();
                count = (long)dtc.Result;
            }
            return(count > 0);
        }
        protected long GetCountCustom(string query)
        {
            try
            {
                string cmdText = "select count(*) from " + Name;
                if (!string.IsNullOrEmpty(query))
                {
                    cmdText += query;
                }

                using (DataCommandBase dtc = new LongDataCommand(cmdText))
                {
                    _file.AddCommand(dtc);
                    dtc.Wait();
                    return((long)dtc.Result);
                }
            }
            catch
            {
                return(0);
            }
        }