Exemplo n.º 1
0
        protected bool SelectColumnsToBeLoaded()
        {
            var         key = Key;
            EntityState state;

            if (!Manager.TryGetTupleOfNonRemovedEntity(ref key, out state))
            {
                return(false);
            }
            var tuple = state == null ? null : state.Tuple;

            if (tuple == null && ColumnIndexesToBeLoaded != null)
            {
                return(true);
            }
            if (ColumnIndexesToBeLoaded != null)
            {
                ColumnIndexesToBeLoaded = null;
            }
            var needToFetchSystemColumns = false;

            foreach (var pair in columns)
            {
                if (tuple == null || !tuple.GetFieldState(pair.Key).IsAvailable())
                {
                    if (pair.Value.IsPrimaryKey || pair.Value.IsSystem)
                    {
                        needToFetchSystemColumns = ExactType && tuple == null;
                    }
                    else
                    {
                        if (ColumnIndexesToBeLoaded == null)
                        {
                            ColumnIndexesToBeLoaded = CreateColumnIndexCollection();
                        }
                        ColumnIndexesToBeLoaded.Add(pair.Key);
                    }
                }
            }
            if (needToFetchSystemColumns && ColumnIndexesToBeLoaded == null)
            {
                ColumnIndexesToBeLoaded = CreateColumnIndexCollection();
            }
            return(ColumnIndexesToBeLoaded != null);
        }
Exemplo n.º 2
0
 public static bool?TryGetExactKeyType(Key key, PrefetchManager manager, out TypeInfo type)
 {
     type = null;
     if (!key.TypeReference.Type.IsLeaf)
     {
         var         cachedKey = key;
         EntityState state;
         if (!manager.TryGetTupleOfNonRemovedEntity(ref cachedKey, out state))
         {
             return(null);
         }
         if (cachedKey.HasExactType)
         {
             type = cachedKey.TypeReference.Type;
             return(true);
         }
         return(false);
     }
     type = key.TypeReference.Type;
     return(true);
 }