public virtual string[] getMedia(string key, string type, string flags)
        {
            media media = new media();

            string[] urls = new string[] { };

            try
            {
                urls = (from t in DB.media
                        where t.type == type && t.mediaKey == key
                        select t.value).Distinct().ToArray();
            }
            catch (Exception e)
            {
                //   Logger.log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, e.ToString());
                throw new DBException();
            }

            return(urls);
        }
        public media getRandomMedia(string type, string[] possibleFlags)
        {
            media media = new media();


            try
            {
                var          mediaRes = DB.media.Where(x => x.mediaKey == type);
                List <media> match    = new List <media>();
                foreach (var f in possibleFlags)
                {
                    var tryMatch = mediaRes.Where(m => m.flags.Contains(f));
                    if (tryMatch.Any())
                    {
                        match.AddRange(tryMatch);
                    }
                }

                if (!match.Any())
                {
                    match.AddRange(mediaRes);
                }

                var rnd = RandomNum.getNumber(match.Count);

                return(match[rnd]);
            }
            catch (Exception e)
            {
                //   Logger.log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, e.ToString());
                throw new DBException();
            }



            return(media);
        }