Here is one approach where we can add items in database context one by one for save data.
List<AuditTrails> auditLogs= new List<AuditTrails>();
foreach (AuditTrail a in auditLogs)
{
if (a.Operation == CreatedBy)
{
if (!string.IsNullOrEmpty(a.NewState))
context.AuditTrails.Add(a);
}
else
context.AuditTrails.Add(a);
}
context.SaveChanges();
Is there any way to do without Loop? I am working with Entity Framework 6. `