Hey SD,
I have an issue with Fetching an Entity Collection when using Parallel processing, although the piece of code should be executed single threaded.
This is my code, the parameters that i pass to FetchEntityCollection are all not null
private T FetchEntity(params object[] parameters)
{
RelationPredicateBucket bucket = new RelationPredicateBucket();
for (int i = 0; i < this.KeyFields.Count; i++)
bucket.PredicateExpression.AddWithAnd(this.KeyFields[i] == parameters[i]);
if (this.CacheBucketFilter != null)
{
foreach (EntityRelation relation in this.CacheBucketFilter.Relations)
bucket.Relations.Add(relation, JoinHint.Left);
}
EntityCollection<T> entities = new EntityCollection<T>();
//The adapter is always new and opened
AdapterManager.Adapter.FetchEntityCollection(entities, bucket, this.CachePrefetchPath); // <-- Getting a null reference exception
T entity = entities.FirstOrDefault();
if (entity != null)
this.AddToCache(entity);
return entity;
}
When i dig deeper i find that a parameter passed in your function is null, this is a piece of code in the PersistenceCore
internal static IEntityCore FindPkObject(Dictionary<int, List<IEntityCore>> parentSideHashes, int childHash, IList childSideFields, IList pkSideFields)
{
IEntityCore toReturn = null;
if(!parentSideHashes.ContainsKey(childHash)) // <-- Comming from here in PresistenceCore, parentSideHashes is null
{
// not there
return toReturn;
}
........
}
But if i look at the calling function MergeNormal then it should not be possible that null gets passed in as a parameter. So i'm a bit lost why this is happening.
It looks like a parallel problem, but in the function where i call the FetchEntityCollection, everything is initiated in the function, so in my logic it can't be a parallel problem, except if the EntityCollection gets cached somewhere else than the adapter.
I Hope you can shed some light at the problem, i have attached an image with 2 printscreens, one with some variables that may be helpfull and one where the exception occures.
I use LLBLGen 4.0, and .net framework 4.0
Attachments
Filename |
File size |
Added on |
Approval |
CombinedImage.png
|
130,903 |
27-May-2014 10:28.59 |
Approved |