matthewschrager / Repository

A generic implementation of the repository pattern in C#.
199 stars 75 forks source link

Why not have a parameterless constructore validation at compile time? #1

Closed weitzhandler closed 12 years ago

weitzhandler commented 12 years ago

Hi I'm just looking at the EFRepository, and I see you throw an exception if the DbContext doesn't have a parameterless constructor, I'm wondering since you can do it all at compile time using the 'new' constraint, example:

public class Repository where TContext : DbContext, new() { }

Check it out: http://goo.gl/Q78AP

weitzhandler commented 12 years ago

OOPS my bad, I didn't even read the code carefully enough :-1:

I didn't notice the context factory thingy, yeah, that's surely the efficient way.

matthewschrager commented 12 years ago

No problem, thanks for the input :)