Contents tagged with .net
As a developer I have a lot of different types of Windows Services installed on my computer for the different projects I work on. Services like MS SQL Server Express, MS SQL Server, IIS, MSMQ and MySQl.
I don't use all of them all of the time, but I would normally leave them running because I couldn't be bothered trawling through all of the services in Services Manager to stop and start them. Having them running all the time made my computer take longer to startup and I felt like it was slowing it down generally and stealing battery power.
So I created My Windows Services Panel as a way to … more
As I talked about in my post Do we need the repository pattern? I’ve been thinking about how we can make a testable data access layer with Entity Framework without using a repository pattern. I showed how you could do that in my post Mocking your Entity Framework data context and testing it in .NET MVC. However losing the repository also loses a nice centralised place to keep your query logic. In this post I’ll show you a nice simple way to use extension methods to do this.
Suppose you’re using Entity Framework to store a collection of foos and there are several places in … more
I explained in my previous post Do we need the repository pattern? why you might want to mock your Entity Framework context rather than using the repository pattern. In this post I’ll show you how to do that and how to test your .NET MVC controllers with a fake data context.
The way you do this varies slightly depending on whether you're using code first or database first. I’ll cover both in this post.
Using Code First in Entity Framework 4
My implementation of code first is based heavily on the blog post by Rowan Miller.
A mockable data context (EF Code First)
When you … more
As we learn new technologies, we discover new mistakes. The Entity Framework makes data access very quick to develop, but also introduces a new set of mistakes that can be made. On my last project I used the Entity Framework Profiler and found my code blighted with a scourge of N+1 problems. I discussed this in my blog post Reviewing my data access layer using the Entity Framework Profiler.
I was also worried that my code wasn’t testable. From what I’d read, the repository pattern seemed to be the agreed best practice for making your data access testable.
However my N+1 problems … more
In HTML when you want to create a box around some content with rounded corners or some other nice feature it would be nice if you could just wrap that content in a <div> or a <section> tag and CSS would do the rest. However this rarely seems to be the case, particularly if you want the HTML to render well in older browsers. The views in my latest .NET MVC 3 project were full of repeated opening and closing sections of HTML for something that we called a chunk, which is just our word for a box with rounded corners that groups together related elements on the page. Sometimes a chunk … more
Inspired by Oren Eini’s series of blog post code reviews and hearing him talk on This Developers Life Life I decided to review the data access of my latest application using the Entity Framework Profiler.
This is the second application I’ve used the Entity Framework for, and I’ve found it a joy to work with. I’d heard the arguments against ORMs that said they can’t produce good SQL, but I’d also heard the argument that ORMs are made by very smart people and they can probably make better SQL than most people. What I hadn’t heard till I heard Oren& … more
Most web security attacks are based on doing unexpected things to user input to fool the website into doing something it shouldn't. As web developers we all know this, but it's hard to keep track of all the exploits that are out there and it's easy to overlook things. The attacks that target the users of a website, work by making them enter unexpected input without them realising it. This often relies on them being logged on to the target site in question so their browser is authenticated when the user clicks on a link in a phishing email.
These notes are about how to avoid making a site … more
Amazon announced in January their new Simple Email Service. This was timely as the project I'm working on at the moment needs to send out quite a lot of transactional emails. A few days later MailChimp announced they'd created a layer on top of the Amazon service that gave some extra and very useful reporting features.
We were sending emails from our webserver's mail server. This was fine most of the time, but even in testing we were finding that a few emails were getting turned down as spam by people’s email clients. Using an email sending service was something we were considering to … more