NPoco 2.0

Today I finally published NPoco 2.0. It has been 6 months in the making and 13 pre-release versions. Thankyou to all who have raised bugs and used it in anger.

Most of the documentation has been published to the github wiki, however if you find something that is missing please let me know and I will endeavour to fix that.

There should be very limited breaking changes in 2.0, but if you have always just passed the connection string to the Database object then nothing will probably change. You can also specify the database type now, by passing ‘DatabaseType.SqlServer2012’ for example into the Database constructor. This will change the way the paging works in this case.

One of the latest features that has made it into 2.0 is the ability to use LINQ to specify simple where clauses, ordering and paging when fetching a single object. For example:

Database.FetchBy<User>(sql => sql.Where(x => x.Name == "Bob")
                                 .OrderBy(x => x.UserId)
                                 .Limit(10, 10))

There is also a FetchWhere<> which only takes a where expression.

Thanks again to all the contributors and if you have any issues be sure to raise them on github.


This entry was posted in .NET and tagged , . Bookmark the permalink.

7 Responses to NPoco 2.0

  1. Marcin B says:

    Congratulations! Will be happy to test it out.

  2. Rhysling says:

    Thank you! NPoco 2.0 is a thing of beauty! As much as I love PetaPoco, I will be switching to NPoco for new projects.

    I really like the Mapper now. It’s so much nicer than the hideous hacking I did to jam my custom types into PetaPoco.cs.

    I have a bunch of highly customized T4 templates which will be easy enough to port over. It was unfortunate that the original PetaPoco templates dumped everything into a single file — simple enough to output entities to separate files, create a separate read-only repo type for views, and generate enums from the DB by convention.

    Question: Do you have an opinion about his approach to TrackModifiedColumns in his PoCo templates by creating a dictionary of the modified column names? It never seemed to work for me, but I may be missing some aspect of the logic.

  3. Rhysling says:

    Snapshotter is a much more elegant and easily understood solution. It’s exactly what I was looking for! Thanks again!

  4. Sarfraz Shah says:

    Thank you! really nice to see updates to this project, i have been using the 1.0.5 via Nuget for most of my projects, excited to see the new features specially Sanpshortter, FetchBy, FetchWhere, unfortunately using (2.0.15 to 2.0.17) I am unable to use these 😦

    listing of my code which works fine with previous version

    Anyway keep up the great effort 🙂

  5. Sarfraz Shah says:

    This is good 🙂 and yes its working now

    Muchas Gracias

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s