:::: MENU ::::
Posts tagged with: c#

Blow up your asp.net/mvc site performence !

Recent technical conversation with few of my  friends ends up with Issue of site speed , no matter what we do the site loads too slow  – and seriously speaking this is something came across me too.  I spent around 2 weeks to find out the better solution to optimize speed of the asp.net / […]


Last week was quite simple and went without trouble  , and just before I start enjoying my weekends – stuck in to in issue of getting ROW_NUMBER() (as we are doing in sandard SQL Query ! Finally come-up with sort and sweet code! var items = context.ItemMasters.AsEnumerable() .Select((u, index) =>  new ItemDetail {    ItemId = […]

Convert List to ObservableCollection Extension Method

Today we found one more interesting thing of converting List to ObservableCollection , Its something you will need regularly when you are working with WPF / Silverlight application – because ObservableCollection typically automatically synchronized when its get updated ! Here is the code may helpful to  you ! , Its extension method to convert into […]

301 Redirect – Using Global.asax

Recently came across new query of redirecting website to new domain , and the trouble was we don’t have control over domain management. Real problem was the hosting doesn’t allow web.config based changes or .htaccess , Finally come across global.asax and piece of code that worked out for me. private void Application_BeginRequest(Object source, EventArgs e) […]

Check Model State Errors

Recently faced new error in MVC3 Project related to Model State , While checking “ModelState.IsValid”  it was always return false , I wasn’t sure whats going wrong with my ModelState Finally got small piece of code that worked out fine for me ! Here it is ,  var errors = ModelState .Where(x => x.Value.Errors.Count > […]

Distinct with LINQ

Here is one more LINQ Problem. Let’s think of scenario having record as below ProductId:1 , ProductName=”Product 1″ , CategoryId=2; ProductId:2 , ProductName=”Product 2″ , CategoryId=3; ProductId:3 , ProductName=”Product 3″ , CategoryId=1; ProductId:4 , ProductName=”Product 4″ , CategoryId=1; ProductId:4 , ProductName=”Product 5″ , CategoryId=2;` And we want the records of Product 1,Product 2, Product 3 […]

String Contains Method with StringComparison

if a string contains another string ignoring the case, there is no method available for string with ignore case we can create extension to string using following ! public static bool Contains(this string original, string value, StringComparison comparisionType) { return original.IndexOf(value, comparisionType) >= 0; } Happy coding !