LINQ tricks for performance (LINQ2SQL Old School)

image.png

I’m working quite a bit on the new Silicon Valley Code Camp site these days and introducing lots of new ways to view sessions.  Much of this code I’ve written over 8 years ago, long before I had so many tricks in my bag. So, one of the things we track is session interest by attendee.  To do that we have two tables, SessionAttendee and Sessions. Doing a simple join and count of the number of SessionAttendee records per session pretty much gives us what we need. Basically, we create a dictionary so we can get all the counts at once so that way, just one sql to the database interestCountsDict = (from data in meta.SessionAttendee where data.Interestlevel == 2 group data by … Continue Reading

Collection Form Post Parameters in WebAPI Controller

image.png

There are lots of ways using ASP.NET MVC4 to collection passed in form parameters (POST) to the WebAPI Controller.  I’m not wanting to create a Model, I’m not wanting to get involved with dynamic variables, I just want the values that are posted in.  Say for example, my post looks like the following: To capture both sessionId and trackId, I can have a WebAPI controller in Visual Studio that looks just like this: namespace WebAPI.Api{ public class SessionRpcController : ApiController { [HttpPost] [ActionName("UpdateSessionTrack")] [Authorize(Roles = "admin")] public HttpResponseMessage PostUpdateSessionTrack( FormDataCollection formDataCollection) … Continue Reading

Why ReSharper Is Worth Using (reason #879)

image.png

  I often email the folks at JetBrains (the makers of ReSharper) letting them know that one of their refactors is wrong.  They often email me back letting me know my about my misunderstanding.  I actually enjoy this. Today, was a perfect example but I did not get past the ReSharper feedback form when I realized my code was wrong (sadly missed the exchange with them).  I’m busy writing the SEO save for Silicon Valley Code Camp’s new web site (coming by next week hopefully).  In this case, I’m looking for a trackId passed into the sessions.aspx page. If I find it, then I redirect to a more friendly URL. Here is my code I was going to complain to ReSharper about as incorrectly warning me that my trackId = –1; is … Continue Reading

ImageResizer, Amazon’s CloudFront and ASP.NET’s MVC4 Razor Helper Methods

image.png

  Well, the title is certainly a mouthful and hopefully a honey trap for SEO.  The thing is, I’m really going to talk about all those things.  I just went through a short exercise that I thought would be useful to share. Background For Silicon Valley Code Camp, I use the toolkit ImageResizer written by  Nathanael Jones.  For those of you that deal with any quantity of images on their web sites, I strongly recommend taking a look at this.  Before I used this toolkit I written my own image handlers that did some similar things but not nearly as well or with so many features.  One of the issues we have on code camp is that we try and show lots of pictures all the time.  Sponsors and speakers are … Continue Reading

Follow

Get every new post delivered to your Inbox

Join other followers: