Hi Jon,

This is from my original post. As you can see it has 3 parameters.
Could you send me source code where you see AddEntityCriteria with one
parameter. Thanks

// Add Entity Crieria
                        if (entityIds != null)
                        {
                            AddEntityCriteria(criteria, alias,
entityType, entityIds);
                        }

On Nov 11, 5:51 pm, "Jon Palmer" <[EMAIL PROTECTED]> wrote:
> From your original post it looks like there is a version of AddEntityCriteria 
> that takes a List<int?> as a parameter.
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jatin
> Sent: Monday, November 10, 2008 8:46 PM
> To: nhusers
> Subject: [nhusers] Re: System.InvalidOperationException. Collection was 
> modified; enumeration operation may not execute
>
> Hi Jon
>
> Here is the AddEntityCriteria() source code.Pl let me know if u need
> any more info. Thanks
>
> private void AddEntityCriteria(ICriteria parentCriteria, string alias,
> string entityTypeName, int? entityId)
>         {
>             if (!string.IsNullOrEmpty(entityTypeName) ||
> entityId.HasValue)
>             {
>                 string setAlias = "ASI";
>                 ICriteria entityCriteria =
> parentCriteria.CreateCriteria(
>                     string.Format("{0}.{1}", alias,
> enumAttributeInstance.AttributeSetInstance), setAlias,
> JoinType.InnerJoin);
>
>                 if (!string.IsNullOrEmpty(entityTypeName))
>                 {
>                     entityCriteria.Add(new
> NHibernate.Expression.EqExpression(
>                         string.Format("{0}.{1}", setAlias,
> enumAttributeSetInstance.EntityTypeName), entityTypeName));
>                 }
>                 if (entityId.HasValue)
>                 {
>                     entityCriteria.Add(new
> NHibernate.Expression.EqExpression(
>                         string.Format("{0}.{1}", setAlias,
> enumAttributeSetInstance.EntityId), entityId.Value));
>                 }
>             }
>         }
>
> On Nov 11, 5:38 pm, "Jon Palmer" <[EMAIL PROTECTED]> wrote:
> > What does AddEntityCriteria look like and how does it use the entryIds?
>
> > -----Original Message-----
> > From: [email protected] [mailto:[EMAIL PROTECTED] On
>
> > Behalf Of Jatin
> > Sent: Monday, November 10, 2008 6:38 PM
> > To: nhusers
> > Subject: [nhusers] System.InvalidOperationException. Collection was
> > modified; enumeration operation may not execute
>
> > Hi All
>
> > I get the following exception when using Criteria objects in
> > NHibernate. The error is only coming up in production and not in Dev
> > or UAT. I am stumped as cant replicate the error and need to fix this
> > asap. The error and the code resulting in the error are below. Any
> > help will be greatly appreciated. I am hitting the database multiple
> > times with the same Nhibernate session. Is that the problem. Thanks
> > Jatin.
>
> > The error :
>
> > Base exception:
> > System.InvalidOperationException
> > Collection was modified; enumeration operation may not execute.
>
> > Stack Trace:
> >    at System.Collections.Hashtable.HashtableEnumerator.MoveNext()
> >    at NHibernate.Impl.Printer.ToString(IEnumerator enumerator)
> >    at NHibernate.Impl.SessionImpl.FlushEverything()
> >    at NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet
> > querySpaces)
> >    at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList
> > results)
> >    at NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria)
> >    at NHibernate.Impl.CriteriaImpl.List[T]()
> >    at
> > GrantEd.UtilityServices.ExtendedAttribute.AttributeInstancePathEvaluator
> > .InternalEvaluate(List`1
> > entities) in C:\UserData\SEMISPT\Source\Development\UtilityServices
> > \ExtendedAttribute\GrantEd.UtilityServices.ExtendedAttribute\Controller
> > \AttributeInstancePathEvaluator.cs:line 121
>
> > The piece of code that results in the error:
>
> > public IAttributeInstances InternalEvaluate(List<KeyValuePair<string,
> > int?>> entities)
> >         {
> >             IAttributeInstances attributeInstances = new
> > AttributeInstances();
> >             using (ISession session =
> > NHibernateSessionManager.Instance.GetSession<AttributeInstance>(_session
> > ))
> >             {
> >                 // Based on List<KeyValuePair<string, int?>> of
> > entities, Get a list per parameter limit
> >                 //(1000 parameters for an IN condition) of List<int?>
> > entityIds.
> >                 Dictionary<string, List<List<int?>>>
> > collectionOfEntityIdsPerParameterLimitByEntityType =
> > GetCollectionOfEntityIdsPerParameterLimitByEntityType(entities);
>
> >                 string alias = "E";
>
> >                 // In case no entities provided, still need to return
> > records matching
> >                 // AttributePath
> >                 if (entities == null || entities.Count == 0)
> >                 {
> >                     ICriteria criteria =
> > InitialiseCommonCriteria(session);
> >                     return new
> > AttributeInstances(criteria.List<AttributeInstance>());
> >                 }
>
> >                 // foreach entityType - loop through each List
> > containg List<int?> items per parameter limit
> >                 // and hit the database and load the
> > IAttributeInstances for each list. Then Merge it and when
> >                 // looped through all return the merged
> > IAttributeInstances.
> >                 // Note: The Reason of seperate hits to the database
> > with each list of 1000 or less parameters in
> >                 // the IN condition is to meet the limitation of
> > parameter size in stored procedures which is                    //
> > 2100. We had attempted to hit database in one go with seperate IN
> > conditions each with a 1000
> >                 // parameters or less but that resulted in an error as
> > soon as number of parameters went to more
> >                 // than 2100.
>
> >                 foreach (string entityType in
> > collectionOfEntityIdsPerParameterLimitByEntityType.Keys)
> >                 {
> >                     foreach (List<int?> entityIds in
> > collectionOfEntityIdsPerParameterLimitByEntityType[entityType])
> >                     {
> >                         ICriteria criteria =
> > InitialiseCommonCriteria(session);
>
> >                          // Add Entity Crieria
> >                         if (entityIds != null)
> >                         {
> >                             AddEntityCriteria(criteria, alias,
> > entityType, entityIds);
> >                         }
>
> >                         // Now that the criteria has been built
> > execute it to resolve the attribute instances
> >                         // and merge it to the running
> > IAttributeInstances List
> >                         attributeInstances.Merge(new
> > AttributeInstances(criteria.List<AttributeInstance>()));
> >                     }
> >                 }
> >             }
>
> >             return attributeInstances;
> >         }- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to