Setting up a new MVC 3 (ASP.NET 4) site, using SQL Session State. Got the message:
Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server
But I *had* set up Session State, so this was perplexing.
Turns out this was because I had only given the ASP.NET user db_datareader and db_datawriter permissions on the Session State database. Those permissions don't allow the user to EXEC sprocs. I gave the user db_owner perms and all was well.
Stupid unhelpful error message!
DaddyCode Team Blog
C# , ASP.NET, MVC, SQL, Sharepoint, JQuery and nowt else from a Web Developer in Leeds
10 Aug 2011
Linq select vs Enumerable.Select()
I found the MSDN docs a bit confusing with this, so here's a brief aide memoire about how to transform a list of one Type to a list of another, using Linq and also Enumerable Linq methods.
In this case I'm transforming from a List of EF Entities (called promotions here) to a list of MVC SelectListItems.
Standard Linq stylee
Enumerable Linq Method stylee
To get a List out, you just do query.ToList().
In this case I'm transforming from a List of EF Entities (called promotions here) to a list of MVC SelectListItems.
Standard Linq stylee
var query = from promo in promotions
select new SelectListItem { Text = promo.Name, Value = promo.Id.ToString() };
Enumerable Linq Method stylee
var query = promotions.Select(promo => new SelectListItem() { Text = promo.Name, Value = promo.Id.ToString() });
To get a List out, you just do query.ToList().
Subscribe to:
Posts (Atom)
If I helped you out today, you can buy me a beer below. Cheers!