예제 #1
0
        public static async Task <IEnumerable <Device> > QueryDevicesAsync(this LakeLabDbContext context, string name)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(await context.Devices.Where(p => p.Name == name).ToListAsync());
        }
예제 #2
0
        public static Task <T> QueryValuesAsync <T>(this LakeLabDbContext context, Func <IQueryable <Value>, Task <T> > queryShaper, Enums.SensorTypes sensorType)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (queryShaper == null)
            {
                throw new ArgumentNullException(nameof(queryShaper));
            }

            return(queryShaper(context.Values.Include(p => p.Device).Where(p => p.SensorType == sensorType)));
        }
예제 #3
0
        public static async Task <Device> QueryDevicesAsync(this LakeLabDbContext context, Guid deviceId)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (deviceId == null)
            {
                throw new ArgumentNullException(nameof(deviceId));
            }

            List <Device> devices = await context.Devices.Where(p => p.Id == deviceId).ToListAsync();

            return(devices.First());
        }