Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add/Insert style of petapoco vs dapper

I am delighted by this:

// Insert a record with peta poco

var a = new Article();
a.title="My new article";
a.content="PetaPoco was here";
a.date_created=DateTime.UtcNow;
db.Insert(a);

I am distracted by this:

// Insert a record with dapper

var a = new Article();
a.title="My new article";
a.content="PetaPoco was here";
a.date_created=DateTime.UtcNow;
string articleQuery= "INSERT INTO Article VALUES (@Title, @Content, @Date)";        
connection.Execute(articleQuery, new { Title = a.Title, Content = a.Content, Date = a.Date });

I am new to dapper and peta poco. It might be that there is more in dapper that I have not found but I really do not like the way I have to do an insert. Peta poco seems to do it very ormish.

Can dapper do this somehow too?

like image 224
Elisabeth Avatar asked Oct 22 '13 18:10

Elisabeth


1 Answers

If you like the PetaPoco style the better, just go for it. Although Dapper is more famous, PetaPoco has the same performance, has the same concepts but it's a bit more flexible (IMO)

like image 141
Eduardo Molteni Avatar answered Oct 12 '22 01:10

Eduardo Molteni