musalman
asked on
Error in LINQ - New transaction is not allowed because there are other threads running in the session
Hi
I am not an experience in LINQ so far, and is having the following error:
New transaction is not allowed because there are other threads running in the session
My code:
--------------
foreach(var ReqDetail in (from row in Db.ReqDetail.With(LockHint .UpdLock)
where row.Company == Session.CompanyID && row.ReqNum == iReqNum
select new { row.PartNum, row.Class, row.LineDesc, row.IUM, row.TranType, row.JobNum, row.Number01, row.XOrderQty, row.ReqNum, row.ReqLine } ) )
{
RFQItem newRow = new RFQItem();
Db.RFQItem.Insert(newRow);
newRow.Company = Session.CompanyID;
newRow.OpenItem = true ;
newRow.RFQNum = (int)iRFQNum ;
newRow.RFQLine = j; //ReqDetail.ReqLine ;
newRow.PartNum = ReqDetail.PartNum;
newRow.ClassID = ReqDetail.Class;
newRow.LineDesc = ReqDetail.LineDesc ;
newRow.IUM = ReqDetail.IUM ;
newRow.PUM = ReqDetail.IUM ;
if (string.Compare(ReqDetail. TranType ,"PUR-UKN",true)==0)
{
newRow.ItemType = "UKN";
}
else if (string.Compare(ReqDetail. TranType ,"PUR-MTL",true)==0)
{
newRow.ItemType = "MTL";
}
else
{
newRow.ItemType = "STK";
}
if (string.Compare(ReqDetail. TranType ,"PUR-MTL",true)==0)
{
newRow.JobNum = ReqDetail.JobNum;
newRow.JobSeq = (int)ReqDetail.Number01;
}
newRow.RequiredQty = ReqDetail.XOrderQty;
newRow.PurchasingFactor = 1 ;
newRow.PurchasingFactorDir ection = "D" ;
newRow.RFQVendQuotes = (int)iQuoteReq;
newRow.Number01 = ReqDetail.ReqNum ;
newRow.Number02 = ReqDetail.ReqLine ;
Db.Validate();
---------------------
The code is pretty simple as it is looking for each line in Requisition detail table and trying to create a RFQ line based on each Requisition line data.
Please suggest - what is causing an error here ?
Note: I have disabled the child records update but still this is throwing the error.
regards
I am not an experience in LINQ so far, and is having the following error:
New transaction is not allowed because there are other threads running in the session
My code:
--------------
foreach(var ReqDetail in (from row in Db.ReqDetail.With(LockHint
where row.Company == Session.CompanyID && row.ReqNum == iReqNum
select new { row.PartNum, row.Class, row.LineDesc, row.IUM, row.TranType, row.JobNum, row.Number01, row.XOrderQty, row.ReqNum, row.ReqLine } ) )
{
RFQItem newRow = new RFQItem();
Db.RFQItem.Insert(newRow);
newRow.Company = Session.CompanyID;
newRow.OpenItem = true ;
newRow.RFQNum = (int)iRFQNum ;
newRow.RFQLine = j; //ReqDetail.ReqLine ;
newRow.PartNum = ReqDetail.PartNum;
newRow.ClassID = ReqDetail.Class;
newRow.LineDesc = ReqDetail.LineDesc ;
newRow.IUM = ReqDetail.IUM ;
newRow.PUM = ReqDetail.IUM ;
if (string.Compare(ReqDetail.
{
newRow.ItemType = "UKN";
}
else if (string.Compare(ReqDetail.
{
newRow.ItemType = "MTL";
}
else
{
newRow.ItemType = "STK";
}
if (string.Compare(ReqDetail.
{
newRow.JobNum = ReqDetail.JobNum;
newRow.JobSeq = (int)ReqDetail.Number01;
}
newRow.RequiredQty = ReqDetail.XOrderQty;
newRow.PurchasingFactor = 1 ;
newRow.PurchasingFactorDir
newRow.RFQVendQuotes = (int)iQuoteReq;
newRow.Number01 = ReqDetail.ReqNum ;
newRow.Number02 = ReqDetail.ReqLine ;
Db.Validate();
---------------------
The code is pretty simple as it is looking for each line in Requisition detail table and trying to create a RFQ line based on each Requisition line data.
Please suggest - what is causing an error here ?
Note: I have disabled the child records update but still this is throwing the error.
regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Great. Now select the answer and submit.
Thank You.
Thank You.
ASKER
Thanks here