原创 MVC Partial頁面的使用

先建立Action:public PartialViewResult CurrentCount() { Vi

原创 完成卸載工具

微軟出的一款專門針對無法安裝和卸載的應用程序的小工具:http://support.microsoft.com/mats/Program_Insta

原创 捕獲Entity framework驗證異常

Entity framework在驗證未通過的時候默認不會拋出詳細異常,這給我們debug帶來很大的困難,不過我們可以手動捕獲,見代碼: private int Update(Employee entity) {

原创 動態構建LINQ(Dynamic String based Queries in LINQ - Dynamic Expression API)

The Dynamic Expression API extends the core LINQ API with the ability to dynamically create string based queries that a

原创 使用Attach和Detach來實現更新的時候避免逐一賦值的麻煩

之前都是用擴展方法來copy屬性值,不過兼容性不是很好。(關於這個擴展方法可以參照這個博客),不過我們可以通過下方的代碼來實現,由於是微軟提供的功能

原创 left join linq

一直沒弄明白linq 的左鏈接查詢,終於找到解決方案了: var result = (from a in table1            join b in table2 on a.a_guid equals b.b_guid i

原创 如何獲取客戶端的IP與MAC地址

轉自  http://www.cnblogs.com/TTTT/archive/2010/02/09/1666147.html [DllImpo

原创 VS無法鏈接遠程數據庫

1. 使用Visual Studio的Server Explore後,會出現VS停止工作錯誤。 2. .NET應用程序連接數據庫時,會出現錯誤消息:The message received was unexpected or badly

原创 其他的項目調用DAL項目中的EF Model

 Based on your description and the error code, you will just need to ensure that your DataContext class inheirits fr

原创 DropdownListFor無法正確綁定值

如果以下面的方式進行綁定: <%: Html.DropDownListFor(model => model.subType, ViewBag.subType as List<SelectListItem>) %> 其中由於model.s

原创 Select top from datatable

 dt = ds.Tables[0].Rows.Cast<System.Data.DataRow>().Take(1).CopyToDataTable(); 點贊 收藏 分享 文章舉報

原创 Update實體時如何避免逐一賦值

使用以下方法可以實現避免Update實體時避免逐一賦值的麻煩。 代碼: public static class ReflectionExtensions { public static void CopyPrope

原创 多線程之線程同步

Pulse(lockObj)表示釋放當前被lock的lockObj,容許其他線程調用。(相當於暫時掛起當前線程) Wait(lockObj)表示等待當前被其他線程佔用的lockObj。 下面的代碼將會交替執行兩個線程: class Ti

原创 GridViewScroll

首先我們需要在下面的鏈接中下載程序包,同時也可以把demo下載下來,下面的代碼就是demo的演示: http://gridviewscroll.aspcity.idv.tw/Demo.aspx <html xmlns="http://ww

原创 多線程之Join

Join方法,其實簡單的說就是阻止主線程運行,直到子線程完成後才繼續執行主線程。注意這裏只是阻止主線程。 下面是個例子: myThread.Join() Console.WriteLine("Child joined"); 運行結果是:先