Ibatis的lazyload失效怎么办?

以前使用DataMapper-1.6.1,现在改用DataMapper-1.5.1,结果lazyload无效了。
以下引用《Data Mapper Guide-1.6.1.chm》中的内容:
3.5.4.9. lazyLoad

Use the lazyLoad attribute with the select attribute to indicate whether or not the select statement's results should be lazy loaded. This can provide a performance boost by delaying the loading of the select statement's results until they are needed/accessed.

Lazy loading is supported transparently for IList and IList<T> implementation.

Lazy loading is supported on strongly typed collection via Castle.DynamicProxy component. In this case you must set the listClass attribute and declare all methods/properties of the typed collection that you want to proxy as virtual.

Lazy loading is supported on concrete class via Castle.DynamicProxy component. In this case, you must declare all methods/properties of the class that you want to proxy as virtual.


在1.5.1版本中,我没有把lazyload属性定义为virtual都可以使用lazyload功能,现在即使声明为virtual也没有效果。调试的过程中发现,属性的第一次读取是肯定为空的,而之后lazyload属性的值却有可能获取。深入分析代码并把1.6.1和1.5.1做比较,无奈水平有限,发现直接相关的代码似乎没有改动,没看出端倪。

在Ibatis.Net的Issue Tracker上看到了此bug的报告,但是没有评论和解决方案。不知道cnblogs上研究Ibatis.Net的牛人能不能提供帮助?实在不行,只有使用1.5.1了。

附代码:
IRegDao dao  =   new  RegDao();
            Reg reg 
=  dao.Find( 1 );
            Console.WriteLine(
" Reg: " );
            Console.WriteLine(
" SeqId:{0} " , reg.SeqId);
            Console.WriteLine(
" SubjID:{0}\tName:{1} " , reg.SubjID, reg.Subj.Name);         

/// class Reg
public  partial  class  Reg
    {
        
#region  Private Member       
        
private   int ?  _SubjID;       
        
#endregion
       
        
#region  Private Extend Member       
        
private  Subj _Subj;
        
#endregion
       
        
#region  Constructor
        
public  Reg()
        {
        }
        
#endregion
       
        
#region  Public Properties       
        
public   int ?  SubjID
        {
            
get  { return  _SubjID;}
            
set  {_SubjID  =  value;}
        }       
        
#endregion
       
        
#region  Public Extend Properties       
        
public   virtual  Subj Subj
        {
            
get  {  return  _Subj; }
            
set  { _Subj  =  value; }
        }
        
#endregion
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值