使用OData時如果遇到model裡面有自訂欄位是資料庫不存在時,就會出現錯誤
解決方案請參閱此篇文章
OData 101: Using the [NotMapped] attribute to exclude Enum properties
使用OData時如果遇到model裡面有自訂欄位是資料庫不存在時,就會出現錯誤
解決方案請參閱此篇文章
OData 101: Using the [NotMapped] attribute to exclude Enum properties
當要同一時間新增大量資料時,如果單純用EF的新增方式,速度會讓人吐血。 所以需要透過BulkInsert的方式處理,但是又不想自己另外寫ado的方式處理,所以就要透過extenstion的方式, 讓EF的功能加強一下
##安裝 EntityFramework.BulkInsert-ef6
##參考文件
http://efbulkinsert.codeplex.com/
##(用法)Demo Code
1 | using(context db = new context()){ |
##執行結果 非常快速
如果利用Code first的方式,搭配DbMigration即可完成工作
1 | public class DemoContext : DbContext |
1 | using System; |
1 | using (var db = new AtaBookContext(connection1)){} |
connection1和connection2分別指到不同的資料庫,EF就會根據連線字串的設定產生相對應的資料庫
當要在htmlHelper裡面使用angularjs的屬性時, 原本的ng-model變成ng_model, 將 - 變成 _ 即可
例如:
1 | @Html.DropDownList("dropdown", (IEnumerable<SelectListItem>)ViewBag.items, new { ng_model = "currentSelect", ng_change = "selectChanges()" }) |
#NOTE: Youtube link: http://youtu.be/S8XL1L_1Lyw
1 | using System; |
1 | using System; |
1 | using System; |
part1
1 | using System; |
執行結果:
part2 (with using())
1 | using System; |
執行結果
part3 with Execute Around Method Pattern
1 | using System; |
執行結果
Ref from G+
Ater upgrading to AS 0.5.4 I am getting this error 「Failed to set up SDK Error:Module 『AndroinoTerm』: platform 『android-18』 not found」 while I already have android-18 installed. My sdk path is correctly setup and I am also able to run my project successfully. Does Anybody else having this issue ?
Solution: 1. Change sdk folder location 2. update sdk path in android studio 3. change back to original location 4. update sdk path setting in android studio again 5. problem solved
當網頁要讀取一個很大量的資料時,通常都會透過分頁的方式來顯示資料。 如果透過WebApi+OData的特性來做分頁,作法很單純 設定 WebApiConfig.cs
1 | //加入 |
假設原本的API寫法如下
1 | [Route("api/Customer")] |
改成
1 | [Route("api/Customer")] |
那在client端要呼叫api的url中,在加上OData的查詢語法來取得所要的資料區段,來達成分頁的效果
指令 | 說明 | 範例 |
---|---|---|
top | 結果挑出最前面的幾筆 | ?$top=3 |
skip | 略過幾筆。可用於分頁顯示 | ?$skip=10 |
orderby | 排序 | ?$orderby=SupplierID,ProductID |
filter | 篩選 | |
gt : > , 大於 | $filter=ProductID gt 10 | |
lt : < , 小於 | $filter=ProductID lt 10 | |
ge : >=, 大於等於 | $filter=ProductID ge 10 | |
le : <=, 小於等於 | $filter=ProductID le 10 | |
eq : =, 等於 | $filter=ProductID eq 10 | |
ne : <>, 不等於 | $filter=ProductID ne 10 |
參考資料: http://msdn.microsoft.com/en-us/library/windowsazure/gg312156.aspx
1 | [Route("api/Customer")] |
要傳入的東西是一樣的,但是回傳的結果會變成
1 | { |
所以在接收時要再調整
所送出的值前面要加上 guid 的關鍵字
1 | ?$filter=field eq guid'<value>' |
In your Windows 8 VM, go to Control Panel > System > Advanced system settings > Computer Name and click Change. Name this whatever you like, e.g. 「windows」. Restart your VM.
Open CMD or Powershell as administrator. Add a URL ACL entry for your new name on the port of your choice, e.g. netsh http add urlacl url=http://windows:8080/ user=everyone
Open CMD or Powershell as administrator. Add an inbound firewall rule for this new port. In Windows 8, the syntax is: netsh advfirewall firewall add rule name=「IISExpressWeb」 dir=in action=allow protocol=TCP localport=8080
In Windows 7, the syntax is: netsh firewall add portopening TCP 8080 IISExpressWeb enable ALL
Edit your IISExpress applicationhost.config file, typically found at your Documents\IISExpress\config\applicationhost.config. Find your site under sites, and add a binding to the port using your machine name, e.g.
Startup IISExpress with Visual Studio, hit your URL from a browser on your Mac/VM Host, e.g. http://windows:8080
Revel in your magnificence.
More info here: http://stackoverflow.com/questions/3313616/iis-express-enable-external-request http://stackoverflow.com/questions/5442551/iisexpress-returns-a-503-error-from-remote-machines http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
c#可以用class轉換成xml, 但是在class裡面的property並不是每一個都需要輸出,有些事非必要性的欄位。 這需要在property欄位另外加上一個欄位來做設定
1 | class demo{ |
[XmlIgnore] : 功用是在輸出xml時,忽略此欄位
依上列的案例來說,如果 field3Specified=true, 則輸出field3欄位, 如果設定成false, 則不輸出field3
在visual studio tools下-> 命令視窗 -> xsd
ref: http://msdn.microsoft.com/en-us/library/x6c1kb0s(v=vs.110).aspx
將.xsd檔案轉換成class的方式為
1 | xsd file.xsd /c |
資本公積是指由股東投入、但不能構成股本或實收資本的資金部分,主要包括股本溢價、接受捐贈實物資產、投入資本匯兌損益、法定財產重估增值以及投資準備金等。
資本公積的來源,按其用途主要包括兩類: 一、超過票面金額發行股票所得之溢額。
二、受領贈與之所得。
資本公積的主要用途有兩個,
公司於完納一切稅捐後,分派盈餘時,應先提出百分之十為法定盈餘公積。但法定盈餘公積,已達資本總額時,不在此限。 除前項法定盈餘公積外,公司得以章程訂定或股東會議決,另提特別盈餘公積。 公司負責人違反第一項規定,不提法定盈餘公積時,各科新臺幣六萬元以下罰金。
惟依據銀行法第50條規定,銀行於完納一切稅捐後分派盈餘時,應先提30%為法定盈餘公積,另證券金融公司亦比照銀行提列30%法定盈餘公積,此為較特殊處。
###其他備註