Questions tagged [npoco]

NPoco is a simple C# micro-ORM that maps the results of a query onto a POCO object.

NPoco is a simple C# micro-ORM that maps the results of a query onto a POCO object.

NPoco is a fork of PetaPoco based on Schotime's branch with a handful of extra features.

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

Make NPoco consider Database default values

Given the following table in my database (PostgreSQL) CREATE TABLE produkt ( id SERIAL NOT NULL, name VARCHAR(50), created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()) ); ALTER TABLE produkt ADD CONSTRAINT…
nozzleman
  • 9,529
  • 4
  • 37
  • 58
6
votes
1 answer

Usage of NPoco in .net Core

I have recently started diving into the new .net core along with asp.net core mvc. There have been several issues that I have come across but have been able to get most of them answered on my own. The one that has really stumped me is the use of…
6
votes
1 answer

mapping complex class with NPOCO

Is it possible to map a complex class with both a nested class and a collection class with NPoco? I've had a look at the documentation but it's not 100% clear whether i can map to this class with one query. For example given these classes: public…
sin cara
  • 123
  • 6
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 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
5
votes
1 answer

NPoco: Update some (but not all) columns using Expression notation

Using NPoco, I'm trying to figure out how to update more than one column of an object (but not all of them). This works... db.Update(item, new[] { "status", "tracking_number", "updated_at" }); ...but I'm trying to use the notation below so I can…
Tony
  • 1,986
  • 2
  • 25
  • 36
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

How can save in the same table a nested object using NPoco?

I have a class like this: public class AuthEntity { public int Id { get; set; } public AuthResource Resource { get; set; } public int ActionId { get; set; } } where AuthResource is: public class AuthResource { public long ResourceId {…
dsancho
  • 51
  • 2
4
votes
1 answer

NPoco: Why is my Delete() call, throwing a NullReferenceException?

I'm trying to use NPoco's Delete() method to delete a row from the database. However it just throws a NullReferenceException. I have found a workaround, but I'm wondering if anyone knows why the built in delete function to delete by ID doesn't seem…
NickG
  • 9,315
  • 16
  • 75
  • 115
3
votes
2 answers

How to get Ids of inserted data in NPoco?

I have a SQL script that when run, inserts rows in 2 tables. How can I access the Ids of newly inserted rows in Npoco. Here is what my SQL looks like: DECLARE @@clientId TABLE (Id INT); INSERT [dbo].[Clients] ([FirstName], [LastName]) OUTPUT…
Farooq Hanif
  • 1,779
  • 1
  • 15
  • 22
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

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

How can I stop MiniProfiler showing "duplicate" SQL query warnings parameters are different?

I'm using MiniProfiler to check what NPoco is doing with SQL Server but I've noticed it reports duplicate queries even when the SQL parameters have different values. Eg: if I fetch a string from a database by ID, I might call: SELECT * FROM…
NickG
  • 9,315
  • 16
  • 75
  • 115
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
1
2 3 4 5 6 7