SlideShare a Scribd company logo
1 of 15
心得分享
李佳駿
MVC
/[Controller]/[ActionName]/[Parameters]
Html.BeginForm("actionName",
"controllerName",
FormMethod.POST,
new{@class="className"})
MVC
<form action="@Url.Action("Index")" method="post">
<input type="text" name="name" />
<input type="submit" value="OK" />
</form>
MVC
@model List<MVCTest.Repository.PatentViewModel>
<table class="table table-striped table table-bordered tipo-
table">
<thead>
<tr>
<th>PN</th>
<th>APN</th>
</tr>
MVC[HttpGet]
[HttpGet]
public ActionResult Index()
{
var repo = new TestRepository();
var viewModel = repo.GetPatentCnData();
return View(viewModel);
}
MVC
[HttpPost]
public ActionResult Index(string name)
{
var repo = new TestRepository();
var viewModel = repo.GetPatentCnData();
return View(viewModel);
}
MVC
HtmlHelper https://msdn.microsoft.com/zh-
tw/library/system.web.mvc.htmlhelper(v=vs.118
).aspx
LINQ DataTable
var zipPathExist =(from count in getAllZipPaths.AsEnumerable()
where count.Field<string>("SourcePath") == zipPath
select count).Any();
Membership
C:windowsMicrosoft.NETFrameworkv2.0.50727 aspnet_regsql.exe
<membership>
<providers>
<clear />
..Connectionstring
</providers>
</membership>
Membership
Membership.CreateUser("aaa", "bbb");
Membership.FindUsersByEmail(String);
Membership.FindUsersByName(String, Int32, Int32, out Int32)
linq to sql
linq to sql
先在MVC的專案 Model資料夾底下 ->新增 dbml 物件
->然後再 Server Explorer 清單上 把所需要的資料庫建立連線
->選擇需要的DataBase表單 直接拖拉進去 dbml檔案內
->建立跟DB連線的 API
->建立一個資料夾(Repository)公司命名習慣
->建立一個CLASS檔案
->如果需要跟DB連線 該類別需要一開始宣告 如下範例 宣告名稱的規則為
linq to sql
dbml檔名+"DataContext"=TestDataContext; (此範例的dbml檔名為test)
private TestDataContext _dc = null;
public TestRepository()
{
_dc = new TestDataContext();
}
_dc.PatentPATN.Where(x => x.PN == "CN1573895").Select(x => new
PatentViewModel() { PN = x.PN, TTL = x.TTL }
Linq to Excel
var excel = new ExcelQueryFactory(filePath);
var sheetName = excel.GetWorksheetNames().First();
//取得Excel表單名稱
ExcelQueryable<Row> sheet = excel.Worksheet(sheetName);
//轉成 linq to Excel
foreach (Row row in sheet.Skip(0)) //sheet.Skip(0) 跳過第0列的資料
{
row["Excel欄位名稱"].Value.ToString().Trim();
//取得Excel欄位名稱為"頻道/節目名稱"的資料
}
out
用法範例 當一個void 要回傳多個值的時候
void Main()
{
int value;
string str1, str2;
Method(out value, out str1, out str2);
}
static void Method(out int i, out string s1, out string s2)
{
i = 44;
s1 = "I've been returned";
s2 = null;
}
IQueryable<T>
只需與 Server 做一次溝通
IEnumerable<T> 把資料部分放在記憶體,有許多where句
時,會多次與Server溝通,利用IQueryable<T>可以有效地
降低server溝通次數
IQueryable<T> 整理出一句SQL句 只需跟伺服器溝通一次
但是SQL句的效率不一定是最有效率

More Related Content

Viewers also liked

Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325LearningTech
 
James elastic search
James   elastic searchJames   elastic search
James elastic searchLearningTech
 
20150213 linq pad_tips
20150213 linq pad_tips20150213 linq pad_tips
20150213 linq pad_tipsLearningTech
 
Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用LearningTech
 
20141107 node js_eventemitterpattern_anney
20141107 node js_eventemitterpattern_anney20141107 node js_eventemitterpattern_anney
20141107 node js_eventemitterpattern_anneyLearningTech
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejsLearningTech
 
Express Web Application Framework
Express Web Application FrameworkExpress Web Application Framework
Express Web Application FrameworkLearningTech
 
An overview of java script in 2015 (ecma script 6)
An overview of java script in 2015 (ecma script 6)An overview of java script in 2015 (ecma script 6)
An overview of java script in 2015 (ecma script 6)LearningTech
 

Viewers also liked (13)

Knockout
KnockoutKnockout
Knockout
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
James elastic search
James   elastic searchJames   elastic search
James elastic search
 
20150213 linq pad_tips
20150213 linq pad_tips20150213 linq pad_tips
20150213 linq pad_tips
 
Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用
 
Lodash js
Lodash jsLodash js
Lodash js
 
20141107 node js_eventemitterpattern_anney
20141107 node js_eventemitterpattern_anney20141107 node js_eventemitterpattern_anney
20141107 node js_eventemitterpattern_anney
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Express Web Application Framework
Express Web Application FrameworkExpress Web Application Framework
Express Web Application Framework
 
An overview of java script in 2015 (ecma script 6)
An overview of java script in 2015 (ecma script 6)An overview of java script in 2015 (ecma script 6)
An overview of java script in 2015 (ecma script 6)
 
node.js errors
node.js errorsnode.js errors
node.js errors
 

Similar to Ken20150313

React vs Flux
React vs FluxReact vs Flux
React vs FluxLC2009
 
前端MVC之backbone
前端MVC之backbone前端MVC之backbone
前端MVC之backboneJerry Xie
 
Ejb工作原理学习笔记
Ejb工作原理学习笔记Ejb工作原理学习笔记
Ejb工作原理学习笔记yiditushe
 
Javascript模板引擎
Javascript模板引擎Javascript模板引擎
Javascript模板引擎Jerry Xie
 
【第一季•第六期】Ajax & JSONP in Action
【第一季•第六期】Ajax & JSONP in Action【第一季•第六期】Ajax & JSONP in Action
【第一季•第六期】Ajax & JSONP in Actiontbosstraining
 
Spring 2.x 中文
Spring 2.x 中文Spring 2.x 中文
Spring 2.x 中文Guo Albert
 
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練5
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練52015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練5
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練5Duran Hsieh
 
jsp基础速成精华讲解
jsp基础速成精华讲解jsp基础速成精华讲解
jsp基础速成精华讲解wensheng wei
 
小谈Javascript设计模式
小谈Javascript设计模式小谈Javascript设计模式
小谈Javascript设计模式Adam Lu
 
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染Sheng-Han Su
 
Rails hackathon
Rails hackathonRails hackathon
Rails hackathon政億 林
 
香港六合彩
香港六合彩香港六合彩
香港六合彩aaveow
 
Django
DjangoDjango
DjangoTao He
 
Http Headers 與 Cache 機制(2016)
Http Headers 與 Cache 機制(2016)Http Headers 與 Cache 機制(2016)
Http Headers 與 Cache 機制(2016)振揚 陳
 

Similar to Ken20150313 (20)

React vs Flux
React vs FluxReact vs Flux
React vs Flux
 
前端MVC之backbone
前端MVC之backbone前端MVC之backbone
前端MVC之backbone
 
Ejb工作原理学习笔记
Ejb工作原理学习笔记Ejb工作原理学习笔记
Ejb工作原理学习笔记
 
Javascript模板引擎
Javascript模板引擎Javascript模板引擎
Javascript模板引擎
 
【第一季•第六期】Ajax & JSONP in Action
【第一季•第六期】Ajax & JSONP in Action【第一季•第六期】Ajax & JSONP in Action
【第一季•第六期】Ajax & JSONP in Action
 
Spring 2.x 中文
Spring 2.x 中文Spring 2.x 中文
Spring 2.x 中文
 
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練5
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練52015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練5
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練5
 
jsp基础速成精华讲解
jsp基础速成精华讲解jsp基础速成精华讲解
jsp基础速成精华讲解
 
小谈Javascript设计模式
小谈Javascript设计模式小谈Javascript设计模式
小谈Javascript设计模式
 
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
 
Vue.js
Vue.jsVue.js
Vue.js
 
Rails hackathon
Rails hackathonRails hackathon
Rails hackathon
 
敦群學院-SharePoint精英計畫-系統開發-Day 2
敦群學院-SharePoint精英計畫-系統開發-Day 2敦群學院-SharePoint精英計畫-系統開發-Day 2
敦群學院-SharePoint精英計畫-系統開發-Day 2
 
Structs2簡介
Structs2簡介 Structs2簡介
Structs2簡介
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
 
ev2oik
ev2oikev2oik
ev2oik
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
 
Django
DjangoDjango
Django
 
Http Headers 與 Cache 機制(2016)
Http Headers 與 Cache 機制(2016)Http Headers 與 Cache 機制(2016)
Http Headers 與 Cache 機制(2016)
 
Java soap
Java soapJava soap
Java soap
 

More from LearningTech

More from LearningTech (20)

vim
vimvim
vim
 
PostCss
PostCssPostCss
PostCss
 
ReactJs
ReactJsReactJs
ReactJs
 
Docker
DockerDocker
Docker
 
Expression tree
Expression treeExpression tree
Expression tree
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection &amp; activator
Reflection &amp; activatorReflection &amp; activator
Reflection &amp; activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 
Asp.net MVC DI
Asp.net MVC DIAsp.net MVC DI
Asp.net MVC DI
 
Vic weekly learning_20151127
Vic weekly learning_20151127Vic weekly learning_20151127
Vic weekly learning_20151127
 
Mocha.js
Mocha.jsMocha.js
Mocha.js
 
R language
R languageR language
R language
 
20151120 ian cocos2d js
20151120 ian cocos2d js20151120 ian cocos2d js
20151120 ian cocos2d js
 

Ken20150313