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
3
votes
0 answers

T4 Template cannot find Oracle.DataAccess

I've a project with .NET 3.5 and PetaPoco 4.0.3 (micro ORM library). I've also a reference to Oracle.DataAccess. PetaPoco is a micro ORM library which has a T4 template to create POCO classes automatically from a Database. Database.ttcontains T4…
miguialberto
  • 316
  • 1
  • 3
  • 14
3
votes
1 answer

Petapoco: Operation could destabilize the runtime

I am trying to use Petapoco's multi-poco query. The code works fine on my local machine running .NET 4.6.1 but throws System.Security.VerificationException when deployed to the hosting I am using which is running .NET 4.5. Snipppet from…
AndreFeijo
  • 10,044
  • 7
  • 34
  • 64
3
votes
1 answer

Petapoco - Couldn't find split point

I have been struggling with peta poco and related classes and are getting the error "Couldn't find split point between PetaPocoProofOfConcept.Resource and PetaPocoProofOfConcept.BookingType". My two classes are: [TableName("Resource"),…
Diemauerdk
  • 5,238
  • 9
  • 40
  • 56
3
votes
1 answer

npoco.Insert fails on table withOUT AutoIncrement Primary key

I have an issue using the 'Insert of T' method of nPoco with a MySQL table defined like: CREATE TABLE `TestTable` ( `Id` INT(11) NOT NULL, `StatusEnum` INT(11) NOT NULL, PRIMARY KEY (`Id`) ) Database.Entity defined…
Tony
  • 1,986
  • 2
  • 25
  • 36
3
votes
2 answers

PetaPoco core .cs file not visible in ASP.NET 5 Class Library package

I am building a new project in ASP.NET 5. In my solution I have added a new Class Library (Package) project. I right click on this project and choose for Manage Nuget packages to install PetaPoco.Core. When I install everything seems fine except…
Mivaweb
  • 5,580
  • 3
  • 27
  • 53
3
votes
2 answers

What is the recommended way to create table with PetaPoco (and NPoco)?

Say I need a table that looks like this: CREATE TABLE Record ( Id INT IDENTITY(1, 1) PRIMARY KEY CLUSTERED, Guid UNIQUEIDENTIFIER UNIQUE NONCLUSTERED, Version ROWVERSION, DateOfBirth DATETIME2, Name VARCHAR(64) NOT NULL ) What's the…
Igor Gatis
  • 4,648
  • 10
  • 43
  • 66
3
votes
1 answer

PetaPoco - Transaction isolation level on insert to DB

Is there a way to set isolation level on Insert to DB using PetaPoco! Transaction locks the database while its not completed, I know there are ways to edit the actual query's or SP's but is there a way to control isolation level via petapoco? It…
Evgeny Lukiyanov
  • 498
  • 1
  • 5
  • 20
3
votes
1 answer

Peta Poco and System.Data.Entity.Spatial.DbGeography

I get an error "Object must implement IConvertible." When I Database db = new Database(this.ConnStr, this.Provider); var x = db.Fetch(sql);//returns the error and myObj has a System.Data.Entity.Spatial.DbGeography property. How can I…
Paul Stanley
  • 1,999
  • 1
  • 22
  • 60
3
votes
2 answers

Error : Index was outside the bounds of the array in Petapoco with Visual Studio 2010

I have define ConnectionStringName and Namespace in Database.tt and using Petapoco 4.0.2 . But when i Save the Database.tt page then follwing error comes : Error 1 Running transformation: System.IndexOutOfRangeException: Index was outside the…
AnUpAm786
  • 31
  • 3
3
votes
2 answers

Can PetaPoco poplulate a list of view models which contain multiple POCOs within each?

I'd like to populate a list of CharacterViewModel with a single query if possible, but I'm unsure how, nor if PetaPoco can even do something like this. This is what the object and query look like: public class CharacterViewModel { public…
Sgraffite
  • 1,898
  • 3
  • 22
  • 29
3
votes
1 answer

How to automatically create concrete classes based on field value

Consider this example: Database (similar to Stackoverflow) has a table with questions and answers in the same table distinguishable by PostType field. I would like to get back a list of lastest posts be it questions or answers. As questions and…
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
3
votes
2 answers

How to generate DDL using PetaPoco or NPoco?

I have just started using PetaPoco/NPoco in one of my projects and have to say that it rocks however, It seems that the library is not able to generate DDL and create a table based on the Poco. I know that OrmLite can do this. Is there a…
MaYaN
  • 6,683
  • 12
  • 57
  • 109
3
votes
0 answers

How do I configure Ninject to create a singleton PetaPoco instance

Getting to grips with Ninject and at the moment and I have the Ninject configuration in my MVC application (which I want to figure out how not to do, but that is a different question). I have several other working configurations, but I don't know…
Paul
  • 1,519
  • 1
  • 16
  • 26
3
votes
2 answers

Workaround for PetaPoco / SQLite aggregate date bug

Here's complete code to create a SQLite database, fill some data into a table and then try to retrieve it. If there's an aggregate function around a datetime column, PetaPoco will throw an error. using System; using PetaPoco; class Program { …
erict
  • 1,394
  • 2
  • 14
  • 28
3
votes
1 answer

Best way to get existence of a row using oracle and petapoco

I am trying to get the existence of a row using Oracle and Petapoco. So far I have the following code. var sql =new Sql("select COUNT(*) FROM myTable where field = 'value'"); var exists = myDB.Query(sql) > 0; This feels kinda dirty as I'm…
Jim Jeffries
  • 9,841
  • 15
  • 62
  • 103