private Model.Location MapEntityToLocation(Location loc) { return new Model.Location { Id = loc.Id, Description = loc.Description, SubdivisionId = loc.SubdivisionId }; }
public static void AddOrUpdate(Location location) { using (var connection = new ReferenceDataEntities()) { Location oldValue = connection.Locations.FirstOrDefault(x => x.Id == location.Id); if (oldValue != null) { connection.Entry(oldValue).CurrentValues.SetValues(location); connection.SaveChanges(); } else { connection.Locations.Add(location); connection.SaveChanges(); } } }