public static void SaveWithFileId <T>(this IEnumerable <T> data, ConstructionDataContext context, int fileId, ILogPrint print = null, IShowProgress showProgress = null) where T : class, IFile { print?.PrintLog($"The file id is {fileId}"); showProgress?.SetMaxValue(data.Count()); int i = 0; foreach (var item in data) { item.FileId = fileId; context.Entry(item).State = EntityState.Modified; showProgress?.SetCurrentValue(i); i++; } print?.PrintLog("Saving data to database."); context.SaveChanges(); showProgress?.Done(); }
protected virtual void UpdateItem(T item) { Context.Entry(item).State = EntityState.Modified; }