예제 #1
0
        //ToDo:非主键字段在数据库上建索引,直接从数据库获取
        public List <T> Get(Expression <Func <T, bool> > selector)
        {
            using (new TimeMonitor(GetPrefix(selector.ToString())))
            {
                try
                {
                    if (IsCacheReady())
                    {
                        return(cache.GetWithList().Where(selector.Compile()).ToList());
                    }

                    return(collection.FindEntitiesAsync(selector).Result);
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    return(new List <T>());
                }
            }
        }