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
6
votes
1 answer

Prevent PetaPoco from recognizing variables as input parameters

I am using PetaPoco.Core 4.0.3 in a C# app to access a MySql database. I'm trying to create a query that uses variables, but I don't want them to be treated by PetaPoco as input parameters. Here is a useless query just to show what I mean: SET @num…
peflorencio
  • 2,284
  • 2
  • 32
  • 40
5
votes
4 answers

Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: meth when running

I am having a project in which I have my API classes and in that project I have generated the Database.cs. In my MVC project I have refenrenced the API. Uppon running the application I am having the error message as follows, can anyone help please…
learning
  • 11,415
  • 35
  • 87
  • 154
5
votes
2 answers

petapoco insert problem

I have a class defined like so: public class Location { public Location() { Meetings = new List(); } public virtual int ID { get; private set; } public virtual string Name { get; set; } public virtual…
Travis Laborde
  • 1,323
  • 1
  • 14
  • 22
5
votes
1 answer

How to set auto incremented id to another column with using Peta Poco

I use C#, SQL Server and PetaPoco which auto increments the ID by default. I just want to know that if it is possible to set this autoincremented id to another column. I have 2 more columns needs to be set with the exact value of ID. Is it possible…
utaco
  • 1,106
  • 8
  • 15
5
votes
2 answers

Is it normal for NPoco/PetaPoco Fetch() to get all data and then filter client side?

I've noticed a huge difference in how NPoco (or PetaPoco) works depending on which function you call when you are using LINQ. For instance compare Fetch() which Query() which both appear to do the same thing: A: Fetch().Where(t =>…
NickG
  • 9,315
  • 16
  • 75
  • 115
5
votes
2 answers

Peta Poco: How to pass multiple parameters to a Fetch

My Code: string sql = "SELECT * FROM people where birthday >= @t1 AND birthday <= @t2" DateTime t1 = DateTime.Parse("01-01-2000"); DateTime t2 = DateTime.Parse("01-01-2001"); var results = db.Fetch(sql, t1,t2); This code produces an…
Paul Stanley
  • 1,999
  • 1
  • 22
  • 60
5
votes
3 answers

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…
Elisabeth
  • 20,496
  • 52
  • 200
  • 321
5
votes
1 answer

Implementing the IMapper interface

I have used PetaPoco in the past, decorating my objects with [Column("{column name")] attributes and so on. However, I'm trying to implement a "pure" domain model that has no knowledge of persistence and therefore no knowledge of PetaPoco's…
Joshua Dutton
  • 1,190
  • 8
  • 11
5
votes
2 answers

Mapping to Dictionary collection in PetaPoco?

way to map the following to a Dictionary?? Sql sql = new Sql() .Append("SELECT Count(*) ") .Append("FROM Custumers") .Append("WHERE CustomerId = @0", Id) var result = database.Fetch>(sql); I cannot use List as DateTime is…
Aakansha
  • 559
  • 2
  • 7
  • 21
5
votes
2 answers

Return Json Using PetaPoco Dynamic & WebAPI

Is it possible to use PetaPoco dynamic query to return Json in the ASP.net WebAPI? //WebAPI Controller public class BranchController : ApiController { public IEnumerable Get() { // Create a PetaPoco database object …
MHop
  • 3,053
  • 3
  • 17
  • 13
4
votes
5 answers

How do I get property names of a type using a lambda expression and anonymous type?

I am trying to use Expression Trees and anonymous types to achieve the following. Let's say I have this class: class Person { public string FirstName {get;set;} public string MiddleName {get;set;} public string LastName {get;set;} public…
Brady Holt
  • 2,844
  • 1
  • 28
  • 34
4
votes
1 answer

PetaPoco query with typed parameters

Using PetaPoco, how do i call stored procedure with typed parameters? in c# i do it like this: cmd.Parameters.Add("@email", SqlDbType.NVarChar).Value = email;
uriz
  • 567
  • 9
  • 25
4
votes
1 answer

How to handle DEFAULT values in database when using PetaPoco insert?

I am converting a legacy application which uses SQL Server and I want to use petapoco for my data access layer. The tables definitions contains a lot of columns with DEFAULT values. I would like my DAL to handle the default value when I insert new…
Larry
  • 17,605
  • 9
  • 77
  • 106
4
votes
1 answer

Executing parameterized stored procedures using PetaPoco

It's been two days I'm wrestling with PetaPoco to implement a search solution (evidently with some search parameters) which has custom paging in database. I couldn't figure out how to configure PetaPoco paging with ASP.NET DataPager (which is a…
user438233
4
votes
1 answer

PetaPoco and output parameters from stored procedures?

I'm trying to setup an output parameter using PetaPoco. I found someone using this sample online: var ctx = new CustomDBDatabase(); var total = new SqlParameter("Total", System.Data.SqlDbType.Int); total.Direction =…
Brian Mains
  • 50,520
  • 35
  • 148
  • 257
1 2
3
28 29