Upload
mis2000-lab
View
119
Download
5
Embed Size (px)
Citation preview
Tech Workshop開放源碼 ASP.NET Core
& ADO.NETMVP (2008~2016)
MIS2000 [email protected]
http://www.dotblogs.com.tw/mis2000lab/
以 “三國演義” 為例
IoT 物聯網、嵌入式系統 [簡報] Arduino、Web 到 IoT http://www.slideshare.net/JustinSDK/arduinoweb-iot
關於 ASP.NET 5(正式版改名為 ASP.NET Core ) 先瞭解 開放原始碼(開源)的 ASP.NET Core
[ 中文翻譯 ] ASP.NET 5 概觀 (ASP.NET 5 Overview ,原作 Tom FitzMacken 2014/11/12) https://dotblogs.com.tw/mis2000lab/2014/12/03/aspnet_5_overvi
ew_webform_46
[ 中文翻譯 ] ASP.NET 5 簡介( Introducing ASP.NET 5 ,原作 ScottGu 2015/2/23 )
https://dotblogs.com.tw/mis2000lab/2015/03/11/aspnet_5_introduce_scottgu_20150223
行前準備 Only VS 2015 (Update 3) VS 2017 RC 版沒這個 Tools
搜尋關鍵字「 ASP.NET Core tools 」
Professional C# 6 and .NET Core 1.0( Wrox 出版社 )
書籍網站&範例下載 -- http://www.wrox.com/WileyCDA/WroxTitle/Professional-C-6-and-NET-Core-1-0.productCd-111909660X.html
我寫好的說明( Blog 文章) & 範例 第一篇: https://dotblogs.com.tw/mis2000lab/2016/08/29/aspnet_core_adonet_begin_01
第二篇:https://dotblogs.com.tw/mis2000lab/2016/08/30/aspnet_core_adonet_begin_02_appsettings
完整文章與操作步驟,收錄在這本書 ASP.NET 學習教材 使用 C# (第二版)。松崗出版。
http://www.books.com.tw/products/0010736860
第一階段,開始囉~ VS 2015 (Update 3) 我預錄的 YouTube 教學影片 --
https://youtu.be/1UaO8C2MnJQ
檢查環境是否可以運作?
Visual Studio 會自動幫您加上 NameSpace ,也會在 project.json 設定檔裡面,加入必要的元件。
第二階段,從「設定檔」讀取連結字串 –appsettings.json
關鍵!重點!! 請在 project.json 裡面加上這一句話,才能讀取
appsettings.json 設定檔 "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true, "copyToOutput": "appsettings.json" },
“ 參數”的寫法,避免 SQL Injection攻擊(跟以前一樣,寫法雷同)var Conn = new SqlConnection(connectionString);Conn.Open();
// 重點!參數的寫法!! var Com = new SqlCommand("Select title from test Where id = @ID", Conn); Com.Parameters.AddWithValue(“@ID", 3); // 分開寫成 .Add() 方法與 Value 屬性,也可運作 using (SqlDataReader dr = Com.ExecuteReader()) { // …… 後續省略……
Q : ADO.NET 怎麼只剩下 DataReader了?以前慣用的 DataSet 呢? 詳見這篇文章的說明 (2016/2/10 發表)
https://blogs.msdn.microsoft.com/dotnet/2016/02/10/porting-to-net-core/
System.Data. While the base layer is already part of .NET Core, i.e. the provider model and SQL client, some features are currently not available, such as schema support and DataTable/DataSet.
System.Transactions. While ADO.NET supports transactions, there is no support for distributed transactions, which includes the notion of ambient transactions and enlistment. (可參閱這本書 -- 深入探索 .NET 資料存取: ADO.NET + SqlDataSource + LINQ ( 松崗 ) )
System.Net.Mail. There is currently no support for sending emails from .NET Core using these APIs.
目前 Core 1.0 不支援,不代表以後不支援。
你幹嘛不一次就給正確範例?程式碼一旦長、一旦多,初學者就會怕!你是來抄程式碼?還是來學習?飛行員 = 飛行時數(經驗值)寫程式 = Debug 時間(經驗值)
上課? 表演?照本宣科,人人都會把上課變成一場秀(表演),其實不容易,需要時間粹練