1. Model:
public class ServicePhotography
{
public string ServiceID { get; set; }
public int ServiceTypeID { get; set; }
public int PackageID { get; set; }
public int Status { get; set; }
public int IsFullPay { get; set; }
public string Contacter { get; set; }
public string ContactPhone { get; set; }
public DateTime BookDateTime { get; set; }
public string BookAddress { get; set; }
public DateTime CreateTime { get; set; }
public Guid UserID { get; set; }
public string Remark { get; set; }
public string GnetePayRecordNo { get; set; }
public decimal Amount { get; set; }
public List<ServiceType> serviceTypeList{get;set;}
}
2. Map:
<resultMap id="ServicePhotographyMap" class="ServicePhotography">
<result property="ServiceID" column="ServiceID"/>
<result property="ServiceTypeID" column="ServiceTypeID"/>
<result property="PackageID" column="PackageID" />
<result property="Status" column="Status" />
<result property="IsFullPay" column="IsFullPay" />
<result property="Contacter" column="Contacter" />
<result property="ContactPhone" column="ContactPhone" />
<result property="BookDateTime" column="BookDateTime" />
<result property="BookAddress" column="BookAddress" />
<result property="CreateTime" column="CreateTime" />
<result property="UserID" column="UserID" />
<result property="Remark" column="Remark" />
<result property="GnetePayRecordNo" column="GnetePayRecordNo" />
<result property="Amount" column="Amount" />
<result property="serviceTypeList" column="ServiceID" select="getServiceTypeList"/> 注意此时的column可以作为getServiceTypeList方法的参数 ,当然不要参数亦可
</resultMap>
<select id="getServiceTypeList" resultMap="ServiceTypeMap">
<![CDATA[SELECT * FROM Service_ServiceType]]>
</select>