KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there a huge difference in performance between the two, for instance I have these two code snippets: public void Insert(IEnumerable<ManageGeofenceViewModel> geofences) { var insertGeofences = new List<Geofence>(); foreach(var geofence in geofences) { Geofence insertGeofence = new Geofence { name = geofence.Name, radius = geofence.Meters, latitude = geofence.Latitude, longitude = geofence.Longitude, custom_point_type_id = geofence.CategoryID }; insertGeofences.Add(insertGeofence); } this.context.Geofences.InsertAllOnSubmit(insertGeofences); this.context.SubmitChanges(); } vs public void Insert(IEnumerable<ManageGeofenceViewModel> geofences) { foreach(var geofence in geofences) { Geofence insertGeofence = new Geofence { name = geofence.Name, radius = geofence.Meters, latitude = geofence.Latitude, longitude = geofence.Longitude, custom_point_type_id = geofence.CategoryID }; this.context.Geofences.InsertOnSubmit(insertGeofence); } this.context.SubmitChanges(); } Which among the two is better and does the two code snippet have the same number of trips to the database since in the 1st snippet submitchanges was called outside of the loop?
Tags (comma-separated)
Save Edits
Cancel