Add / Paste style petapoco vs dapper

I am delighted :

// 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 as follows:

// Insert entry 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. Maybe in what I haven't found yet, but I really don't like the way I should do the insertion. Peta Poco seems to be doing this very nicely.

Can it do this anyway?

+4
source share
3 answers

Discard the expansion dapper for operations with a mask CRUD with Dapper:

using (SqlConnection cn = new SqlConnection(_connectionString))
{
    cn.Open();
    Person person = new Person { FirstName = "Foo", LastName = "Bar" };
    int id = cn.Insert(person);
    cn.Close();
}

Also see this thread for more ...

+5
source

PetaPoco, , . Dapper , PetaPoco , , (IMO)

+12

Developers use Drapper because of its performance. For many sites, PetaPoco is good enough, but if you want to extract all the server juice, use Drapper. This is actually the ORM used by Stackoverflow. You can see all ORM performance comparison here

0
source

All Articles