我需要一些幫助來理解這個問題。我正在使用ActiveRecordMediator存儲庫 模式。我已啓用會話範圍http 模塊,用ActiveRecord標記我的類(Lazy = true)。Castle ActiveRecord懶惰加載不工作
問題是,我每次執行FindAll或SlicedFindAll, 調解器都會返回一組初始化元素而不是 代理。有人能指出我在正確的方向嗎?
這是我的倉庫:
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; }
}
}
}
當我執行的FindAll方法,在版本中的所有對象 陣列的DocumentEntity是DocumentVersionEntity代替 DocumentVersionEntityProxy和都intialized。
我在做什麼錯?
交叉發佈(附答案):http://groups.google.com/group/castle-project-users/browse_thread/thread/863f02fbc6ba52e8 – 2010-12-15 20:24:31
是的,我想我也可以在城堡項目組中提問。儘管如此,我的情況仍然沒有回答。 – 2010-12-15 22:24:00