public void NotifyOwnerAboutKeyWithUnknownType()
 {
     if (needToNotifyOwner && Task != null)
     {
         referencingFieldDescriptor.NotifySubscriber(ownerKey, Key);
     }
 }
Exemplo n.º 2
0
        public void UpdateCache()
        {
            if (itemsQueryTask == null)
            {
                return;
            }
            var areToNotifyAboutKeys = !manager.Owner.Session.Domain.Model
                                       .Types[referencingFieldDescriptor.Field.ItemType].IsLeaf;
            var reader     = manager.Owner.Session.Domain.EntityDataReader;
            var records    = reader.Read(itemsQueryTask.Result, QueryProvider.Header, manager.Owner.Session);
            var entityKeys = new List <Key>(itemsQueryTask.Result.Count);
            List <Pair <Key, Tuple> > auxEntities = null;
            var association = ReferencingField.Associations.Last();

            if (association.AuxiliaryType != null)
            {
                auxEntities = new List <Pair <Key, Tuple> >(itemsQueryTask.Result.Count);
            }
            foreach (var record in records)
            {
                for (int i = 0; i < record.Count; i++)
                {
                    var key = record.GetKey(i);
                    if (key == null)
                    {
                        continue;
                    }
                    var tuple = record.GetTuple(i);
                    if (tuple == null)
                    {
                        continue;
                    }
                    if (association.AuxiliaryType != null)
                    {
                        if (i == 0)
                        {
                            auxEntities.Add(new Pair <Key, Tuple>(key, tuple));
                        }
                        else
                        {
                            manager.SaveStrongReference(manager.Owner.UpdateState(key, tuple));
                            entityKeys.Add(key);
                            if (areToNotifyAboutKeys)
                            {
                                referencingFieldDescriptor.NotifySubscriber(ownerKey, key);
                            }
                        }
                    }
                    else
                    {
                        manager.SaveStrongReference(manager.Owner.UpdateState(key, tuple));
                        entityKeys.Add(key);
                        if (areToNotifyAboutKeys)
                        {
                            referencingFieldDescriptor.NotifySubscriber(ownerKey, key);
                        }
                    }
                }
            }
            manager.Owner.UpdateState(ownerKey, ReferencingField,
                                      ItemCountLimit == null || entityKeys.Count < ItemCountLimit, entityKeys, auxEntities);
        }