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
9
votes
2 answers

Mapping to collection in PetaPoco?

Is there a way to map the following to a Dictionary? It seem it produces rows for as many returned results there are, but they have no values... Sql sql = new Sql() .Append("SELECT Count(*) as 'Answer Count', QuestionId") …
chobo
  • 31,561
  • 38
  • 123
  • 191
8
votes
1 answer

In PetaPoco, how to decorate a table that has multi-columns primary keys

In the example given on PetaPoco's web site, this is how to decorate a class: [PetaPoco.TableName("articles")] [PetaPoco.PrimaryKey("article_id")] public class article { public long article_id { get; set; } public string title { get; set; } …
Kevin Le - Khnle
  • 10,579
  • 11
  • 54
  • 80
8
votes
1 answer

Can the multimapping of Petapoco handle multiple JOINs?

I have a list objects I use to fill using Petapoco. The class properties and names are maching the database schema. The main class is Issue, and it is related to two other classes which names and properties matches the database schema too :…
Larry
  • 17,605
  • 9
  • 77
  • 106
8
votes
3 answers

PetaPoco - setting transaction isolation level

Using PetaPoco, you're allowed to do transaction management doing something like this: var newObject = new NewObject(); var newObjectId = 1; using (var scope = db.GetTransaction()) { newObject = db.SingleOrDefault("SELECT * FROM…
antinescience
  • 2,339
  • 23
  • 31
8
votes
1 answer

Pass table value param to stored procedure using PetaPoco

For while I am trying to call SQL Server 2008 R2 stored procedure using PetaPoco. My stored procedure accepts a table valued parameter. How I can call the stored procedure in petapoco with table value param? Here what I am trying to do: var db =…
8
votes
3 answers

How to modify PetaPoco class to work with Composite key comprising of non-numeric columns?

I have a table with following columns: ContractorId ......... INT ............. IDENTITY ContractorName ........ Varchar(50) ....... P.K ContractorGrade ....... Varchar(3) ....... P.K The class generated by PetaPoco T4 template looks like…
RKh
  • 13,818
  • 46
  • 152
  • 265
8
votes
2 answers

How to unit test service that is using PetaPoco.Database

I am using PetaPoco on my current project as a micro ORM and i must say that i like it. However, i found myself struggling with simple scenario - unit testing services that use PetaPoco.Database public class MyService : IMyService { private…
ljubomir
  • 1,495
  • 1
  • 21
  • 40
6
votes
1 answer

Have I misunderstood the PetaPoco.IgnoreAttribute?

I have a table containing service announcements. For this table I have a 1:1 POCO - except that it contains one extra field. In my query this is the joined in username of the author, the table contains just the author id. I thought that I could just…
Christian Wattengård
  • 5,543
  • 5
  • 30
  • 43
6
votes
3 answers

PetaPoco and Many-to-One, One-to-Many and Many-to-Many relations

PetaPoco has introduced Multi-POCO queries in experimental form (for now). As their blog post suggests and the code it provides this looks nice and all in One-to-One relations when we load multi POCOs per row as long as they don't repeat over the…
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
6
votes
1 answer

PetaPoco + unit of work + repository pattern

The code below seems to work using this: var unitOfWorkProvider = new PetaPocoUnitOfWorkProvider(); var repository = new FakeRepository(); var fake = new Fake { // etc. }; using (var uow =…
cs0815
  • 16,751
  • 45
  • 136
  • 299
6
votes
5 answers

PetaPoco.Database implements IDisposable, so why don't most examples have a 'using' statement?

The PetaPoco.Database object implements IDisposable but I rarely if ever see code samples (including on PetaPoco's own website) that include a using statement as follows: using (var db = new Database("MyConnectionString")) { // Do database…
Howiecamp
  • 2,981
  • 6
  • 38
  • 59
6
votes
2 answers

Is PetaPoco deprecated? should I use NPoco now? (2013 Q3)

I'm starting some new projects and I want to use PetaPoco (I've used it before in other projects) or NPoco. I know NPoco is a branch of PetaPoco (based on v4.x), and PetaPoco is now in v5.x. But it seems that althought NPoco is PetaPoco + some new…
Luis
  • 1,840
  • 2
  • 14
  • 14
6
votes
2 answers

PETAPOCO - Invalid object name

I am using CTE with PetaPOCO and getting a strange error SQL Exception: Invalid Object Name PayTransactionForRollingVacationAverage that references the model that the data should map to. The code is as follows. public…
InvisibleDog
  • 231
  • 3
  • 4
6
votes
2 answers

PetaPoco vs NPoco

NPoco seems to be a DLL that implments more advanced features of PetaPoco. PetaPoco installs code generation templates and PetaPoco.cs. The Nuget version of PetaPoco is 4.0.3. I know there are versions (ie., 4.0.12) that implement some of the…
Guy--L
  • 170
  • 2
  • 13
6
votes
3 answers

PetaPoco Transaction in Multithread Env

I just test PetaPoco Transaction in a multithread way... I have a simple test case : -- Simple value object call it MediaDevice -- Insert a record an update it for 1000 times void TransactionThread(Object object) { Database db = (Database)…
Novalis
  • 2,265
  • 6
  • 39
  • 63
1
2
3
28 29