Example #1
0
        public async Task <IList <Device> > GetAllFromMongoAsync()
        {
            using (var context = _contextFactory.GetMongoContext())
            {
                var devices = await context.OnlineDevices.FindAsync(_ => true);

                var mappedDevices = new List <Device>();

                await devices.ForEachAsync(item =>
                {
                    var entity = _mapper.Map <Device>(item);
                    mappedDevices.Add(entity);
                }).ConfigureAwait(false);

                return(mappedDevices);
            }
        }