using (var db = new PTO_SystemEntities())
{
var pto = db.PTO_REQUEST
.Where(q => q.Status != "Cancelled" && q.Status != "Processed" && q.Type != "Reverse Leave");
foreach (var i in pto)
{
Console.Write(i.EMPLID.Trim() + ", " + location.Trim() + ", " + jobcode.Trim() + ", " + i.Hours + Environment.NewLine);
[b] db.Entry(i).Property(e => e.Status).CurrentValue = "Processed";
db.Entry(i).Property(e => e.Status).IsModified = true;
db.SaveChanges();[/b]
}
}
"New transaction is not allowed because there are other threads running in the session."
using (var db = new PTO_SystemEntities())
{
var pos = db.PTO_REQUEST
.Where(q => q.Status != "Cancelled" && q.Status != "Processed" && q.Type != "Reverse Leave");
foreach (var i in pos)
{
//whatever code here
using (var dd = new PTO_SystemEntities())
{
dd.PTO_REQUEST
.Where(q => q.ID == i.ID)
.ToList()
.ForEach(a => a.Status = "Processed");
dd.SaveChanges();
}
}}
You state the following, "This is the idea (in bold), but doesn't work.", how does it not work, do you get a run time error or compile error or something else?
Please also post the schema of the PTO_REQUEST table from the database.