One of the most common questions I get when people see a video or presentation about how I build MVC applications is, “Why don’t you use the repository pattern?” There are a lot of reasons not to use the repository pattern, and they’ve been well-covered by others. But, one valid benefit they provide is encapsulation…
try-catch-FAIL
Tag: <span>EntityFramework</span>
Returning Multiple Result Sets from a Stored Procedure Using Entity Framework 6
I know, I know, you’re already rolling your eyes! “Stored procedures??!?” But hey, sometimes a stored procedure is the best solution to a problem! Entity Framework allows you to call stored procedures quite easily out of the box, but working with sprocs that return multiple result sets isn’t so easy. Here’s a handy extension method…
Entity Framework, Enums, and TINYINT
Entity Framework supports Enum properties on your model, but there’s one little gotcha that’s bitten me on more than one occasion now. In your database, you may be tempted to save space by configuring the backing column to use an integer value that takes up less space than a normal int, such as a TINYINT…
Random Link Roundup–12/4/2014
Happy Friday, everyone! Today we have a zombie picture, because my house is contaminated with a mixture of flu and stomach virus that I’m pretty sure will lead to the scene below. Anyway, on to the links! [more] First, a few useful new things you may want to bookmark: BootstrapBay is yet another place to…
Random Link Roundup–9/25/2014
It’s the last Friday of September. Time for another cat pic and some links! [more] I’ve been working on some simplified ASP.NET Identity samples lately, something that shows how cleanly it can be implemented if you remove some of the bad design and noise that the VS project template adds. These two posts were very…
Random Link Roundup–9/19/2014
It’s Friday, which means another round-up of useful links. Oh, and a cat picture! [more] There’s some really cool stuff coming with C# 6.0. Check out some of the enhancements! Be sure to check out EntityFramework.Extended if you are using Entity Framework. It adds support for future queries, caching, and auditing to EF. Want to…
Making TransactionScope Work with async/await in .NET 4.5
I ran into a frustrating little problem today. I’m getting started with Entity Framework 6 and its async features on a new project, and my SpecsFor integration tests were bombing out unexpectedly. In turns out the problem was caused by TransactionScope and async work together out of the box. Or rather, how they don’t work…
A Generic Entity Framework 5 Repository With Eager-Loading
I’ve been doing some work with Entity Framework 5 lately. Here’s a simple generic repository I created that allows you to “Include” related entities by applying an attribute. [more] Consider these sample entities: public class User { [Key] public int UserId { get; set; } [Required, MaxLength(50)] public string Username { get; set; } [Required]…