private static void SequenceRecords(DbUpdateGroup group) { if (group == null || group.Records.Count < 2) { return; } // check if we need extra record sequencing, for records in non-trivial topological groups var extraSeqRecords = group.RecordsForExtraSequencing; if (extraSeqRecords != null && extraSeqRecords.Count > 1) { AssignSubIndexes(extraSeqRecords); } // actually sort records by entity.TopologicalIndex, record.SubIndex, record.EntityName switch (group.Order) { case DbUpdateOrder.Update: case DbUpdateOrder.Delete: case DbUpdateOrder.IsolatedDelete: // direct order group.Records.Sort((x, y) => RecordsSortComparer(x, y, 1)); break; case DbUpdateOrder.Insert: case DbUpdateOrder.IsolatedInsert: // reverse topological order group.Records.Sort((x, y) => RecordsSortComparer(x, y, -1)); break; } }
private DbUpdateGroup GetCreateUpdateGroup(DbUpdateOrder order) { var group = UpdateGroups.FirstOrDefault(g => g.Order == order); if (group != null) { return(group); } group = new DbUpdateGroup(order); UpdateGroups.Add(group); return(group); }
private void CreateTableGroups(DbModel dbModel, DbUpdateGroup group) { DbUpdateTableGroup currGroup = null; foreach (var rec in group.Records) { if (currGroup == null || rec.EntityInfo != currGroup.Table.Entity) { var tbl = dbModel.GetTable(rec.EntityInfo.EntityType); currGroup = new DbUpdateTableGroup(tbl, ToOperation(group.Order)); group.TableGroups.Add(currGroup); } currGroup.Records.Add(rec); } //foreach rec }