Questions tagged [petapoco]

PetaPoco is a tiny and fast micro-ORM for .NET and Mono.

PetaPoco is a tiny and fast single-file or library referenced micro-ORM for .NET and Mono. It prides itself on being an easy to use and no fuss. Support for all the common databases engines are included (SQL Server, SQL Server CE, MS Access, SQLite, MySQL, MariaDB, PostgreSQL, and Oracle databases).

Single file

PetaPoco is available as a single file nuget package, with or without T4 templates to generate POCOs from an existing database schema. In the single file form PetaPoco has zero dependencies.

Speed

PetaPoco benchmarks done by the author can be found here. (Note that there have been several performance improvements made in the code since these benchmarks.)

Frans Bouma's benchmarks can be found here


See the PetaPoco website for a full list of features.

429 questions
35
votes
5 answers

How do I use the SQL WHERE IN construct with PetaPoco?

I have a database table named Tags (Id, Name) from which I would like to select the ones where the name matches a name in a list. In SQL I would use something like: Select * from Tags Where Name In ('Name1', 'Name2', 'xxx...) But now using PetaPoco…
Mitch99
  • 353
  • 1
  • 4
  • 6
23
votes
6 answers

PetaPoco: How to use the SQL Like keyword ( WHERE Name LIKE '%@0%')

What is the correct syntax for this query? var l=db.Fetch
("SELECT * FROM articles WHERE title LIKE '%@0%'", 'something'); Or should I use CHARINDEX?
Eduardo Molteni
  • 38,786
  • 23
  • 141
  • 206
22
votes
4 answers

How to check a var for null value?

I am using PetaPoco Micro-ORM with C# 4.0. The code below retrieves a single row from the database: var result = db.SingleOrDefault(getUserQuery); I would like to check whether or not the result contains any rows, and whether is null. What…
RKh
  • 13,818
  • 46
  • 152
  • 265
21
votes
3 answers

Calling stored procedures with parameters in PetaPoco

I want to be able to call a stored proc with named parameters in PetaPoco. In order to call a stored proc that does a search/fetch: Can I do something like this: return db.Fetch("EXEC SP_FindCust", new SqlParameter("@first_name",…
Tech Xie
  • 927
  • 4
  • 12
  • 24
21
votes
9 answers

Bulk insert/Update with Petapoco

I'm using the Save() method to insert or update records, but I would like to make it perform a bulk insert and bulk update with only one database hit. How do I do this?
silba
  • 239
  • 1
  • 2
  • 6
18
votes
4 answers

Does PetaPoco handle enums?

I'm experimenting with PetaPoco to convert a table into POCOs. In my table, I've got a column named TheEnum. The values in this column are strings that represent the following enum: public enum MyEnum { Fred, Wilma } PetaPoco chokes when…
Steve Dunn
  • 21,044
  • 11
  • 62
  • 87
16
votes
4 answers

Execute stored procedure with PetaPoco

I have a stored procedure which returns back a table value. Here is my stored procedure: PROCEDURE [GetPermitPendingApproval] @permitYear int = NULL, AS BEGIN SELECT [p].[ID] ,[p].[PermitNumber] …
Sam
  • 171
  • 1
  • 2
  • 11
15
votes
2 answers

how to create a DAL using petapoco

I need to create a DAL and repositories using petapoco. The difficulty that comes in, is that I dont know how it manages its connections. If I was using dapper I know how the connection process flows because I control it. I don't know what are the…
David
  • 5,403
  • 15
  • 42
  • 72
13
votes
1 answer

Parameter '@home' specified but none of the passed arguments...Error message

I am having an sql statement as follows: SELECT [User].[ID], [User].[Name], [User].[Email] FROM [User] WHERE Email = 'user@home.com'' and it's firing an error as follows from petaPOCO: Parameter '@home' specified but none of the…
learning
  • 11,415
  • 35
  • 87
  • 154
13
votes
2 answers

What is the difference between Fetch and Query?

To me, PetaPoco's Database.Fetch and Database.Query seem to be doing the same thing. For example, var db = new PetaPoco.Database("myDB"); ProductList products = db.Fetch("SELECT * FROM ProductList"); ProductList products =…
jkl
  • 675
  • 2
  • 8
  • 23
12
votes
3 answers

PostgreSQL: 42883 Operator does not exist: timestamp without time zone = text

I am using Npgsql 3.0.3.0 and PetaPoco latest version. When I run this command: var dateCreated = DateTime.Now; // just an example var sql = new Sql("WHERE date_created = @0", dateCreated.ToString("yyyy-MM-dd HH:00:00")); var category =…
AndreFeijo
  • 10,044
  • 7
  • 34
  • 64
12
votes
3 answers

Best strategies when working with micro ORM?

I started using PetaPOCO and Dapper and they both have their own limitations. But on the contrary, they are so lightning fast than Entity Framework that I tend to let go the limitations of it. My question is: Is there any ORM which lets us define…
Jack
  • 7,433
  • 22
  • 63
  • 107
10
votes
1 answer

PetaPoco - Multiple result set support

My work recently starting using PetaPoco and although fantastic I missed the feature from Dapper which allowed multiple result grids from a single query to be processed into pocos. As a result I wrote my own implementation for PetaPoco - shown below…
Morphed
  • 3,527
  • 2
  • 29
  • 55
9
votes
2 answers

PetaPoco Insert - Fastest Method?

What is the fastest option for inserting records into the database: using which of these: Database.Insert(poco) Database.Insert(tableName, pkName, poco) Database.Save(poco) Database.Save(tableName, pkName, poco) Which one should I use for…
Brian Mains
  • 50,520
  • 35
  • 148
  • 257
9
votes
5 answers

PetaPoco insert fails on table with trigger

We are using PetaPoco as our data access tool for a SQL 2008 database. We have a problem when trying to insert/update a row on a table that has a trigger attached. We are using PetaPoco's db.Save(object); The error shown is: The target table…
Pete Lunenfeld
  • 1,557
  • 3
  • 19
  • 32
1
2 3
28 29