a problem with parallel.foreach in initializing conversation manager
Posted
by
Adrakadabra
on Stack Overflow
See other posts from Stack Overflow
or by Adrakadabra
Published on 2010-12-26T06:19:06Z
Indexed on
2010/12/26
13:54 UTC
Read the original article
Hit count: 190
nhibernate
|mvc
i use mvc2, nhibernate 2.1.2 in controller class i call foreachParty method like this:
OrganizationStructureService.ForEachParty<Department>(department, null, p =>
{
p.AddParentWithoutRemovingExistentAccountability(domainDepartment, AccountabilityTypeDbId.SupervisionDepartmentOfDepartment);
}
}, x => (!(x.AccountabilityType.Id == (int)AccountabilityTypeDbId.SupervisionDepartmentOfDepartment)));
static public void ForEachParty(Party party, PartyTypeDbId? partyType, Action action, Expression> expression = null) where T : Party { IList chilrden = new List(); IList acc = party.Children;
if (party != null)
action(party);
if (partyType != null)
acc = acc.Where(p => p.Child.PartyTypes.Any(c => c.Id == (int)partyType)).ToList();
if (expression != null)
acc = acc.AsQueryable().Where(expression).ToList();
Parallel.ForEach(acc, p =>
{
if (partyType == null)
ForEachParty<T>(p.Child, null, action);
else
ForEachParty<T>(p.Child, partyType, action);
});
}
but just after executing the action on foreach.parallel, i dont know why the conversation is getting closed and i see "current conversation is not initilized yet or its closed"
© Stack Overflow or respective owner