ibatis.net:第八天,QueryForDictionary

时间:2022-03-20 22:54:30

xml

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

代码

1         public static void FindOrdersForDictionary()
2         {
3             var mapper = Mapper.Instance();
4 
5             var orders = mapper.QueryForDictionary<int, Order>("FindOrdersByCustomer", "段光伟", "Id");
6             Console.WriteLine(orders.Count);
7         }

备注

使用到 QueryForDictionary 的机会好像并不多。