ibatis.net:第七天,QueryWithRowDelegate

xml

1     <statement id="FindOrdersByCustomer" parameterClass="string" resultClass="Order">
2       SELECT Id, Customer FROM [Orders] WHERE Customer = #value#
3     </statement>

代码

 1         public static void FindOrdersWithRowDelegate()
 2         {
 3             var mapper = Mapper.Instance();
 4 
 5             var orders = mapper.QueryWithRowDelegate<Order>("FindOrdersByCustomer", "段光伟", (item, customer, items) =>
 6             {
 7                 items.Add(item as Order);
 8             });
 9             Console.WriteLine(orders.Count);
10         }

备注

QueryWithRowDelegate 主要应对的场景是:希望对返回的对象做一个后续处理。需要注意的是:在回调方法中,必须手工将对象添加到集合中,否则返回的集合中不会包含这个对象。

 

你可能感兴趣的:(delegate)