"a query like the one I'm attempting to perform would be really
expensive to the database since it has more properties with relations"
this is vague statement.
How expensive is the query?
Why is it expensive?
Quantifying the answers will give you the information required to
resolve the bottleneck.
In any case proxied entities wouldn't resolve the expense/bottleneck.

something ORM's have taught me is there is a balance between the
number of queries executed and the amount of data returned. the
obvious goal is to reduce the number of remote calls. I have found
that sometimes it's better to issue multiple queries with smaller sets
of data, than issue one query that retrieves everything.

The best techniques I have found for improving database performance
are properly indexing the database, limiting the results returned by
the query and batching reads and writes. after that I try to limit the
number of joins per query. as a last restore to improve performance I
introduce caching.

On Dec 15, 4:11 pm, Diego AC <[email protected]> wrote:
> So there's no way to perform a FindAll or a HQL query to retrieve lazy-
> loaded entities? I mean, a query like the one I'm attempting to
> perform would be really expensive to the database since it has more
> properties with relations. There must be other way, ain't it?
>
> On Dec 15, 1:44 pm, Jason Meckley <[email protected]> wrote:
>
> > proxies are only returned when calling Load<> or when a referenced
> > entity is accessed. neither of which is the case here. here are some
> > examples. this is NH code, but it should all be the same for AR since
> > AR is using NH under the hood.
>
> > session.Get<Entity>(id);// returns the actual object
> > session.Load<Entity>(id);// returns a proxy of the object. note this
> > will throw if the entity doesn't actually exist
>
> > var entity = session.Get<Entity>(id);
> > var other = entity.ReferencedEntity; //returns a proxy of the
> > referenced entity
>
> > var entities = session.CreateCriteria<Entity>().List<Entity>(); //
> > returns a list of actual objects
> > foreach(var entity in entities)
> > {
> >    var other = entity.ReferencedEntity; //returns a proxy of the
> > referenced entity
>
> > }
>
> > On Dec 15, 12:35 pm, Diego AC <[email protected]> wrote:
>
> > > Hi,
>
> > > I need some help in understanding this issue. I'm using the repository
> > > pattern with ActiveRecordMediator. I've enabled the session scope http
> > > module, marked my classes with the ActiveRecord(Lazy = true).
>
> > > The problem is that each time I perform a FindAll or SlicedFindAll,
> > > the mediator returns a collection of initialized elements instead of
> > > proxies. Could someone point me out in the right direction?
>
> > > This is my repository:
>
> > > public interface IEntityRepository<TEntity>
> > > {
> > >        IList<TEntity> FindAll(int page, int pageSize, out int
> > > resultCount);
>
> > > }
>
> > > public class EntityRepository<TEntity> : IEntityRepository<TEntity>{
> > >        public virtual IList<TEntity> FindAll(int page, int pageSize)
> > >        {
> > >             return
> > > (IList<TEntity>)ActiveRecordMediator.SlicedFindAll(typeof(TEntity),
> > > (page * pageSize), pageSize);
> > >        }
>
> > > }
>
> > > [ActiveRecord(Lazy = true)]
> > > public class DocumentEntity
> > > {
> > >         private Guid _id;
> > >         private IList<DocumentVersionEntity> _versions;
>
> > >         [PrimaryKey(PrimaryKeyType.GuidComb, "Id")]
> > >         public virtual Guid Id
> > >         {
> > >             get { return _id; }
> > >             set { _id = value; }
> > >         }
>
> > >         [HasAndBelongsToMany(typeof(DocumentVersionEntity),
> > > RelationType.Bag, Table = DocumentEntriesToDocumentVersions",
> > > ColumnKey = "DocumentEntryId",
> > >                              ColumnRef = "DocumentVersionId", Cascade
> > > = ManyRelationCascadeEnum.AllDeleteOrphan, Lazy = true)]
> > >         public virtual IList<DocumentVersionEntity> Versions
> > >         {
> > >             get { return _versions; }
> > >             set { _versions = value; }
> > >         }
>
> > > }
>
> > > [ActiveRecord(Lazy = true)]
> > > public class DocumentVersionEntity
> > > {
> > >         private Guid _id;
>
> > >         [PrimaryKey(PrimaryKeyType.GuidComb, "Id")]
> > >         public virtual Guid Id
> > >         {
> > >             get { return _id; }
> > >             set { _id = value; }
> > >         }
>
> > > }
>
> > > When I execute the FindAll method, all the objects in the Versions
> > > array of the DocumentEntity are DocumentVersionEntity instead of
> > > DocumentVersionEntityProxy and are all intialized.
>
> > > What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to