The lazyload feature is inevitable when ibatisnet is used, which can achieve delayed loading and improve database access efficiency. But be careful when using lazyload. Do not forget to add the attribute that requires lazyload.VirtualKeyword. Otherwise, delayed loading cannot be implemented (I found that loading can be delayed during single-step debugging ).
Ing file:
< Resultmap ID = "Applicationresult" Class = "Application" >
< Result Property = "ID" Column = "ID" Dbtype = "Guid" />
< Result Property = "Yearnum" Column = "Yearnum" />
< Result Property = "Budget. xmlvalue" Column = "Budget" />
< Result Property = "Studentinfo" Column = 'Id' Select = "Application. selectstudentinfo" Lazyload = "True" />
< Result Property = "Teacherinfo" Column = "ID" Select = "Application. selectteacherinfo" Lazyload = "True" />
</ Resultmap >
Corresponding Model
[Serializable]
Public Class Application
{
# Region Model
Private Guid _ id = Guid. empty;
Private Ilist < Studentinfo > _ Students = New List < Studentinfo > ( 0 );
Private Ilist < Teacherinfo > _ Teachers = New List < Teacherinfo > ( 0 );
Public Application ()
{}
Public Guid ID
{
Set {_ Id = Value ;}
Get { Return _ Id ;}
}
Public Virtual Ilist < Studentinfo > Studentinfo
{
Get { Return _ Students ;}
Set {_ Students = Value ;}
}
Public Virtual Ilist < Teacherinfo > Teacherinfo
{
Get { Return _ Teachers ;}
Set {_ Teachers = Value ;}
}
}
The lazyload feature is inevitable when ibatisnet is used, which can achieve delayed loading and improve database access efficiency. But be careful when using lazyload. Do not forget to add the attribute that requires lazyload.VirtualKeyword. Otherwise, delayed loading cannot be implemented (I found that loading can be delayed during single-step debugging ).
Ing file:
< Resultmap ID = "Applicationresult" Class = "Application" >
< Result Property = "ID" Column = "ID" Dbtype = "Guid" />
< Result Property = "Yearnum" Column = "Yearnum" />
< Result Property = "Budget. xmlvalue" Column = "Budget" />
< Result Property = "Studentinfo" Column = 'Id' Select = "Application. selectstudentinfo" Lazyload = "True" />
< Result Property = "Teacherinfo" Column = "ID" Select = "Application. selectteacherinfo" Lazyload = "True" />
</ Resultmap >
Corresponding Model
[Serializable]
Public Class Application
{
# Region Model
Private Guid _ id = Guid. empty;
Private Ilist < Studentinfo > _ Students = New List < Studentinfo > ( 0 );
Private Ilist < Teacherinfo > _ Teachers = New List < Teacherinfo > ( 0 );
Public Application ()
{}
Public Guid ID
{
Set {_ Id = Value ;}
Get { Return _ Id ;}
}
Public Virtual Ilist < Studentinfo > Studentinfo
{
Get { Return _ Students ;}
Set {_ Students = Value ;}
}
Public Virtual Ilist < Teacherinfo > Teacherinfo
{
Get { Return _ Teachers ;}
Set {_ Teachers = Value ;}
}
}