我需要一些帮助来理解这个问题。我正在使用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