Ejemplo n.º 1
0
        public List <LogMessage> GetLogs(String criteria, int skip, int take)
        {
            var hasCriteria = !String.IsNullOrWhiteSpace(criteria);
            var searchText  = hasCriteria ? criteria.ToLowerInvariant() : "";

            try
            {
                IOrderedQueryable <LogDBMessage> queryable = _realm.All <LogDBMessage>().OrderByDescending(msg => msg.Timestamp);

                var enumerator = queryable.GetEnumerator();

                int i = 0;
                while (i < skip && enumerator.MoveNext())
                {
                    i++;
                }

                var result = new List <LogDBMessage>(take);
                i = 0;

                while (i < take && enumerator.MoveNext())
                {
                    if (hasCriteria && enumerator.Current.Message.ToLowerInvariant().Contains(searchText))
                    {
                        result.Add(enumerator.Current);
                    }
                    if (!hasCriteria)
                    {
                        result.Add(enumerator.Current);
                    }

                    i++;
                }

                return(Mapper.Map <List <LogMessage> >(result));
            }
            catch (Exception ex)
            {
                Logger.Technical.From <RealmLoggingDbCtx>().Exception(ex).Log();
                return(new List <LogMessage>());
            }
        }
 public IEnumerator <T> GetEnumerator()
 {
     return(_baseQueryable.GetEnumerator());
 }
Ejemplo n.º 3
0
 public IEnumerator <TSource> GetEnumerator() => queryable.GetEnumerator();
 public IEnumerator <T> GetEnumerator()
 {
     return(_sourceQuery.GetEnumerator());
 }