コード例 #1
0
        private EntityGroupTask CreateTask()
        {
            TypeInfo exactReferencedType;
            var      hasExactTypeBeenGotten = PrefetchHelper.TryGetExactKeyType(Key, Manager, out exactReferencedType);

            if (hasExactTypeBeenGotten != null)
            {
                if (hasExactTypeBeenGotten.Value)
                {
                    Type = exactReferencedType;
                    //FillColumnCollection();
                    needToNotifyOwner = false;
                }
                else
                {
                    needToNotifyOwner = true;
                }
            }
            else
            {
                return(null);
            }
            FillColumnCollection();
            if (!SelectColumnsToBeLoaded())
            {
                return(null);
            }
            Task = new EntityGroupTask(Type, ColumnIndexesToBeLoaded.ToArray(), Manager);
            return(Task);
        }
コード例 #2
0
        private void RegisterFetchByKnownForeignKey(PrefetchFieldDescriptor referencingFieldDescriptor,
                                                    EntityState ownerState)
        {
            var association        = referencingFieldDescriptor.Field.Associations.Last();
            var referencedKeyTuple = association
                                     .ExtractForeignKey(ownerState.Type, ownerState.Tuple);
            var referencedKeyTupleState = referencedKeyTuple.GetFieldStateMap(TupleFieldState.Null);

            for (var i = 0; i < referencedKeyTupleState.Length; i++)
            {
                if (referencedKeyTupleState[i])
                {
                    return;
                }
            }
            var session       = Manager.Owner.Session;
            var referencedKey = Key.Create(session.Domain, session.StorageNodeId,
                                           association.TargetType, TypeReferenceAccuracy.BaseType,
                                           referencedKeyTuple);
            var      targetType       = association.TargetType;
            var      areToNotifyOwner = true;
            TypeInfo exactReferencedType;
            var      hasExactTypeBeenGotten = PrefetchHelper.TryGetExactKeyType(referencedKey, Manager,
                                                                                out exactReferencedType);

            if (hasExactTypeBeenGotten != null)
            {
                if (hasExactTypeBeenGotten.Value)
                {
                    targetType       = exactReferencedType;
                    areToNotifyOwner = false;
                }
            }
            else
            {
                return;
            }
            var fieldsToBeLoaded = PrefetchHelper
                                   .GetCachedDescriptorsForFieldsLoadedByDefault(session.Domain, targetType);
            var graphContainer = Manager.SetUpContainers(referencedKey, targetType,
                                                         fieldsToBeLoaded, true, null, true);

            if (areToNotifyOwner)
            {
                graphContainer.RootEntityContainer.SetParametersOfReference(referencingFieldDescriptor, referencedKey);
            }
        }