visual studio 2017
在工具選項的javascript/TypeScript的Language Service 把啟用新的JavaScript Language Service的打勾移除
另外作法:
在js檔中加入下列一段,會自動參考(版本自行替換)
/// <reference path="Scripts/jquery-2.0.0.min.js" /> /// <reference path="Scripts/jquery-2.0.0.intellisense.js" />
2017年10月19日 星期四
dapper 連接資料庫
連接資料庫有ado.net,dapper,Entity Framework
Imports System.Transactions //可以加快速度
1.開啟NuGet管理視窗下載Dapper
C#
顯示在gridview
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = ReadAll();
GridView1.DataBind();
}
public class conference
{
public 資料庫欄位型別 資料庫欄位名稱 { get; set; }
//出來的資料也只有定義在類別(這裡)的資料
}
public List<con> ReadAll()
{
using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["xxx"].ConnectionString))
{
return db.Query<con>
("Select * From 資料庫 m" Where xxx=@xxx",
new { xxx = 1 }).ToList();
}
}
2017年10月18日 星期三
MVC api教學網站
http://kirkchen.logdown.com/pages/use-aspnet-mvc-to-develop-api
http://kirkchen.logdown.com/posts/246422-aspnet-mvc-using-aspnet-idetity-integrate-google-login
http://kirkchen.logdown.com/posts/246422-aspnet-mvc-using-aspnet-idetity-integrate-google-login
2017年10月17日 星期二
C#return和yield return心得
return
yield return
yield return 會回到以前的程式執行,看起來都是迴圈之類的程式 ,不斷地把符合程式的資料丟出來,return大概只會丟一次
public static void foreach(Collection<String> collection) {
Iterator<String> iterator = collection.iterator();
while(iterator.hasNext()) {
System.out.println(iterator.next());
}
}
現在,無論是List或Set,無論真正的實作是ArrayList、LinkedList、HashSet...,都可以使用這個foreach方法來 顯示內部所收集的物件。
int x = (int)Days.Sun;
string y = Days.Sun.ToString();
Console.WriteLine("Sun = {0}", x);---->得到位置的值 0
Console.WriteLine("Fri = {0}", y);------>得到值 sum
enum Days { Sun, Mon, Tue, Wed, Thu, Fri, Sat };
可能是方便給值又有數字 就是每個值都要代表的數字 方便取值
和swich使用
structure
structure enum class 一ㄗ
可不用宣告
不用new
表某一個群組
像是 structure 農場
{
雞
鴨
}
yield return
yield return 會回到以前的程式執行,看起來都是迴圈之類的程式 ,不斷地把符合程式的資料丟出來,return大概只會丟一次
public static void foreach(Collection<String> collection) {
Iterator<String> iterator = collection.iterator();
while(iterator.hasNext()) {
System.out.println(iterator.next());
}
}
現在,無論是List或Set,無論真正的實作是ArrayList、LinkedList、HashSet...,都可以使用這個foreach方法來 顯示內部所收集的物件。
int x = (int)Days.Sun;
string y = Days.Sun.ToString();
Console.WriteLine("Sun = {0}", x);---->得到位置的值 0
Console.WriteLine("Fri = {0}", y);------>得到值 sum
enum Days { Sun, Mon, Tue, Wed, Thu, Fri, Sat };
可能是方便給值又有數字 就是每個值都要代表的數字 方便取值
和swich使用
structure
structure enum class 一ㄗ
可不用宣告
不用new
表某一個群組
像是 structure 農場
{
雞
鴨
}
class TheClass { public int x; } struct TheStruct { public int x; } class TestClass { public static void structtaker(TheStruct s) { s.x = 5; } public static void classtaker(TheClass c) { c.x = 5; } public static void Main() { TheStruct a = new TheStruct(); TheClass b = new TheClass(); a.x = 1; b.x = 1; structtaker(a); classtaker(b); Console.WriteLine("a.x = {0}", a.x); Console.WriteLine("b.x = {0}", b.x); } }雖然感覺用不到
訂閱:
文章 (Atom)