public async Task CreateAsync(Device device) { _context.Attach(device); _context.Entry(device).State = EntityState.Added; await _context.SaveChangesAsync(); _context.Entry(device).State = EntityState.Detached; }
public async Task CreateAsync(string sensorId, int deviceId) { var sensorDevice = new SensorDevice { DeviceId = deviceId, SensorId = sensorId }; _context.Attach(sensorDevice); _context.Entry(sensorDevice).State = EntityState.Added; await _context.SaveChangesAsync(); _context.Entry(sensorDevice).State = EntityState.Detached; }
public async Task CreateAsync(string sensorId, int labelNumber, double match) { var soundLog = new RecognizedSoundLog { LabelNumber = labelNumber, Match = match, SensorId = sensorId, CreationDate = DateTime.UtcNow }; _context.Attach(soundLog); _context.Entry(soundLog).State = EntityState.Added; await _context.SaveChangesAsync(); _context.Entry(soundLog).State = EntityState.Detached; }