JeremySkinner / WebMatrix.Data.StronglyTyped

Strongly typed query extensions for WebMatrix.Data
http://www.jeremyskinner.co.uk
Apache License 2.0
10 stars 4 forks source link

use new() contraint in Mapper.cs #1

Open guillaume86 opened 13 years ago

guillaume86 commented 13 years ago

Hi,

I was looking at your Mapper.cs source code and was wondering why you didn't just use the "where T : new()" contraint and new T() contructor in place of your CreateActivatorDelegate method, since it will throw an exception if a parameterless constructor is not found anyway.

Actually I wrote myself a small lib for sql access and the my Mapper class looks pretty much like yours (same trick to set properties really fast ^^), the only difference I found is in the constuctor call.

JeremySkinner commented 13 years ago

Good question. I was originally going to support non-default constructors where the user could supply their own activator delegate, with the default being used if the user didn't specify one. However, I decided not to do this for simplicity so there really is no benefit to not using the new constraint with the current implementation.

guillaume86 commented 13 years ago

ok thanks for the answer ;)