PetaPoco - Version 3.0.0

Friday, 29 April 2011

PetaPoco version 3 is now available incorporating lots of minor changes - one of which is not backwards compatible requiring clocking the major version number.

This post is about PetaPoco - "a tiny ORMish thing for your POCOs". Read more on the PetaPoco Project Page.

Here's a summary of what's new. All of these changes I've discussed in previous blog posts, except for the new KeepConnectionAlive property which I'll write up soon.

  • New - KeepConnectionAlive property
  • New - support for single column value requests
  • New - schema tweaking in T4 template
  • New - support for non-autoincrement primary key columns
  • Improved - automatically parenthesize expression in Sql.Builder.Where
  • Improved - allow escaping of @ symbol on any data provider
  • Improved - T4 template support for SQL Server geo types
  • Fixed - no automatic insertion of SELECT clause on CALL and EXECUTE statements
  • Fixed - escaping of table names in generated SQL
  • Fixed - T4 template where column names conflict with other methods/properties
  • Fixed - column name escaping for Oracle

Available now in GitHub and NuGet.

« PetaPoco - Single Column Value Requests Showcase Lane - Getting Close »

4 Comments

Very impressive to be at version 3 already!

4 May 2011 09:41 PM
Horst

I just wanted to thank you for your efforts and for sharing PetaPoco. It has become a great tool and I admire how much progress you made in such a short time.

Thanks!

11 May 2011 03:10 PM

Im using PetaPOCO in this open source framework.

http://lessframework.codeplex.com/documentation with reference to PetaPOCO

Keep good work, and thanks for sharing your efforts

16 May 2011 09:29 PM

Thanks for the great tool! Have you thought about adding better stored procedure support? The big hurdle I saw was getting the output parameters. My class uses the generic System.Data interfaces like IDbCommand, but it has to query sys.objects and sys.all_parameters to get the names, types and directions of parameters so it only works for SQL Server. Also to keep it simple I make the last argument be an ExpandoObject so I can cast it to IDictionary<string, object> for setting parameter values. This lets you call it like so (@In1 and @In2 are input parameters, @Out1 and @Out2 are output parameters and @ReturnCode is hard-coded for the return value):

eo = new ExpandoObject(); eo.In1 = 1; eo.In2 = 2; dynamic r = db.ExecuteProc<dynamic>("TestProc", eo); WriteLine("ReturnCode: {0}", r.ReturnCode); WriteLine("Out1: {0}", r.Out1); WriteLine("Out2: {0}", r.Out2); WriteLine("Rows: {0}", r.Items.Count)

"r.Items" is the list that would be generated by calling Query<dynamic> instead. I added them to a list instead of yielding results in an enumeration because I didn't know how to do in a property, maybe I could change Items to a GetResults function on the result object that would return an enumeration?

I don't understand the code in GetFactory very well, so I created a class that implements IDataReader and the methods needed to create the factory and create the objects based on the IDbCommand parameters instead of an actual data reader, then I create a factory and use it for the output parameters when the stored procedure executes.

21 May 2011 12:39 AM

Leave a comment

Name (required)
Email (required, not shown, for gravatar)
Website (optional)
Your Message
Leave these blank: