I am having problems with LINQ to SQL objects:
// Context is DataContext that was auto genereted when i create my .dbml file var cl = Context.Classes.ToArray(); var rm = Context.Rooms.ToArray(); List<DaySchedule> s = new List<DaySchedule>(); s.Add(new DaySchedule() { Class = cl[0], DayOfWeek = 0, Pair = 1, Room = rm[0] }); Context.SubmitChanges();
so after "SubmitChanges" the new DaySchedules will be saved in db. BUT I did not call the InsertOnSubmit function, and I do not want to save this DaySchedule.
BTW, if I use the following code:
s.Add(new Acceron.University.DBAccess.DaySchedule() { Class_id = cl[0].Class_ID, DayOfWeek = 0, Pair = 1, Room_id = rm[0].Room_ID });
It will not be automatically saved in db.
Could you explain that this is a bug or function and how can I solve it?
source share