發表文章

目前顯示的是有「asp.net mvc」標籤的文章

Caffeine+ Boost Your Productivity

圖片
Most people wouldn't doubt that coffee shop is one of the best places to work, since it seems to have certain magic power to make people being highly productive. But, do we must go into the coffee shop in order to enjoy the cozy atmosphere? The answer now is "NO"!! The app called "Caffeine" could able to give you a portable coffee shop anytime and anywhere you like. You could have all of the coffee shop buzz you want without trying hard to fight for a seat in the real shop, or spend much money to buy latte one after another. "Caffeine", an awsome app which re-create the coffee shop atmosphere for you by serving you many coffee shop buzz easily. You can mix one unique coffee shop buzz along with your own beloved music together to play at a time. Oh, and don't forget to help yourself to make a cup of coffee before you start to stick to this app!! Now, with "Caffeine", who will say that we must go to the real coffee shop to enj...

快速將List中重覆資料排除

最近工作的關係要從不同的table來撈資料。對於Linq不太熟的我真的是一大挑戰。 以前用SQL就可以很快的將不同table組在一起同時可以做group資料。現回到Linq上來 Linq也可以做grounp資料。但是如果中間做了很多復雜的查詢與應用到~可能不太方便用group的話…雖然網路上有很多方法是用泛型加foreach的方式去比較,但是操作上可能還是有點復雜與要再加工一下…這個時候可以用下列的方法做處理。 var list = new List<string> {"A", "C", "B", "D", "A", "B", "E", "D", "B", "C"};     var set = new HashSet<string>(list);  foreach (string item in set)    {      Console.WriteLine(item);     }

關於DbUpdateConcurrencyException

Building an MVC 4 App with Database First and Entity Framework 最近遇到的專案,是已經有大量的資料在資料庫裡。對於這種情況,就不適合使用 比較熟悉的code first的方式來開發,所以將採用DB First的方式來進行。當我們用 ADO.NET Entity Data Model,visual studio 將會為我們先建立好相關的類別、模 型。 在這個時候問題來了,採用這種方式的話,我們在code first中,我們會直接把 表單驗證的條件寫在model中,但是db first的方式,我們取得的model是經由範本 產生的,所以當我們資料庫有做了異動,或是我們的model有做更新的話,我們把 驗證的條件寫在自動產生的model中,將會全被清掉。 在自動產生的類別可以看到這幾行的註解。 //------------------------------------------------------------------------------ // <auto-generated> //    This code was generated from a template. // //    Manual changes to this file may cause unexpected behavior in your application. //    Manual changes to this file will be overwritten if the code is regenerated. // </auto-generated> //---------------------------- 所以這時候我們將要用到Buddy Class的幫忙。 例如一開始我們建立的model如下 :  namespace MvcLeaning . Models {     using System ;     usin...