Esempio n. 1
0
        public EntityBase GetEntityById(Type type, object id)
        {
            if (id == null)
            {
                return(null);
            }
            ILoader loader = GetLoader(type);

            if (!ClassFactory.GetObjectDescription(type, this).IsAggregated)
            {
                EntityBase e = Caches.GetEntityById(loader.ReflectedType, id);
                if (e == null)
                {
                    if (_loadAllOnGetById && !ClassFactory.GetObjectDescription(type, this).IsDenyGetAllOnGetById)
                    {
                        List <EntityBase> temp = GetEntities(type);
                        e = Caches[loader.ReflectedType].Contains(id) ? Caches[loader.ReflectedType][id] : null;
                    }
                    else
                    {
                        e = loader.LoadEntityById(id);
                    }
                }
                return(e);
            }
            else
            {
                AgregatedClassAttribute aggr = ClassFactory.GetObjectDescription(type, this).GetAttribute <AgregatedClassAttribute>();
                List <EntityBase>       l    = new List <EntityBase>();
                foreach (Type t in aggr.ChildTypes)
                {
                    EntityBase e = GetEntityById(t, id);
                    if (e != null)
                    {
                        return(e);
                    }
                }
                return(null);
            }
        }