I've been using LINQ (with SqlMetal) a lot lately with MVC. I needed to grab a random single record. To my surprise there didn't appear to be a way to do this. I found an interesting post that confirms this and provides a workaround.
http://weblogs.asp.net/fmarguerie/archive/2008/01/10/randomizing-linq-to-sql-queries.aspx
The workaround is to create a function which returns a newid. As the function can be mapped by SqlMetal the function will be available for sorting server side. Interesting… just a shame the function NEWID() isn't part of DLINQ.
I decided to use the MVC Preview 4 Account Controller with my MVC application. The application has been following the StoreFront sample application which is using StructureMaps. The trick in getting the two to work together is the following in configure()
ForRequestedType<IFormsAuthentication>()
.TheDefaultIsConcreteType<FormsAuthenticationWrapper>();
ForRequestedType<MembershipProvider>()
.TheDefaultIs(Membership.Provider);
In this way the web.config values are used for the provider. Without passing Membership.Provider (say by passing a new SQL provider) the configurations will be defaulted.
Scott Hanselman recently made RockScroll available to the public here, http://www.hanselman.com/blog/IntroducingRockScroll.aspx. The add-on, if you haven't tried it, is great. One of its most useful features is highlighting in red a selected keyword both inline and in the scroll bar. It allows you to quickly, and visually find all instances of a term. The add-on has a minor bug though, it doesn't account for collapsed regions. So if regions are collapsed the scrolling will not line up with the code.
David Yack posted, http://weblogs.asp.net/mrdave/archive/2004/09/17/230732.aspx, a list of some shortcuts which are particularly handy for...
This made me feel a little bit better today. : )