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.

Adam

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. Schotime says:

    Hi @Rhysling,

    Thanks.
    As to your question, the modified columns should work as it passes the column names to the Update method. This will only create an update statement based on those column names.
    I use the Snapshotter built into NPoco to achieve the same thing. https://github.com/schotime/NPoco/wiki/Change-tracking-for-updates

    Cheers,
    Adam

  4. Rhysling says:

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

  5. 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 http://pastebin.com/3irDaFzn which works fine with previous version

    Anyway keep up the great effort :)
    Saludos!

  6. Schotime says:

    Thanks for that.
    I have fixed and put up a new version. 2.0.18.
    Adam

  7. Sarfraz Shah says:

    This is good :) and yes its working now

    Muchas Gracias

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>