PetaPoco has a couple of really easy ways of inserting/updating records.
The following are the object initializations used below:
private PetaPoco.Database ppObj = new PetaPoco.Database("[connection string name]");
ClassName.ObjName objInstance = new ClassName.ObjName();
ClassName.ObjName objInstance = new ClassName.ObjName();
One way is to create an object based upon the class created from the database.tt file and use the insert()/update() method:
objInstance.Insert();
As I found out, this approach does not allow you to rollback a transaction. If you run the insert()/update() on the PetaPoco object instead then you can rollback transactions:
ppObj.Insert(objInstance);
No comments:
Post a Comment