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"