public static Dictionary <IProperty, object> GetDatabaseValues(this StateEntry stateEntry, DbContext context) { if (stateEntry.EntityType.Type == typeof(Driver)) { var id = (int)stateEntry.GetPrimaryKeyValue().Value; return(context.Set <Driver>() .Where(d => d.Id == id) .Select(d => d.GetValues(stateEntry.EntityType)) .SingleOrDefault()); } if (stateEntry.EntityType.Type == typeof(Engine)) { var id = (int)stateEntry.GetPrimaryKeyValue().Value; return(context.Set <Engine>() .Where(d => d.Id == id) .Select(d => d.GetValues(stateEntry.EntityType)) .SingleOrDefault()); } return(null); }
internal void Delete(StateEntry stateEntry) { _rows.ExchangeValue(rs => rs.Remove(stateEntry.GetPrimaryKeyValue())); }
internal void Update(StateEntry stateEntry) { _rows.ExchangeValue(rs => rs.SetItem(stateEntry.GetPrimaryKeyValue(), stateEntry.GetValueBuffer())); }
internal void Create(StateEntry stateEntry) { _rows.ExchangeValue(rs => rs.Add(stateEntry.GetPrimaryKeyValue(), stateEntry.GetValueBuffer())); }