dapper簡單實用

IDbConnection dbConnection = new SqlConnection("server=.\\sqlexpress;uid=sa;pwd=123;database=InterviewTest2;");

return dbConnection.Query<Model.NetAddress>("select * from NetAddress").ToList();

 

datatable:

IDbConnection dbConnection = new SqlConnection("server=.\\sqlexpress;uid=sa;pwd=123;database=InterviewTest2;");         DataTable dt = new DataTable();         dt.Load(dbConnection.ExecuteReader(@"SELECT Delivery.DeliveryDate,DeliveryGoods.Goods_No, DeliveryDetail.ColorID, DeliveryDetail.Quantity , CONVERT(int, DeliveryDetail.Quantity) * CONVERT(int, DeliveryGoods.UnitPric) as totalCount  FROM Delivery LEFT JOIN DeliveryGoods ON Delivery.DeliveryID = DeliveryGoods.DeliveryID LEFT JOIN DeliveryDetail ON DeliveryGoods.DeliveryGoodsID = DeliveryDetail.DeliveryGoodsID"));         string json = JsonConvert.SerializeObject(dt);         Response.Write(json);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章