petapoco

Petapoco: Operation could destabilize the runtime

心不动则不痛 提交于 2019-12-10 20:15:13
问题 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 PetaPoco/Database.cs:2253 while (true) { TRet poco; try { if (!r.Read()) break; poco = factory(r, cb); // <-- The exception happens here } catch (Exception x) { if (OnException(x)) throw; yield break; } if (poco != null) yield return poco; else bNeedTerminator

PetaPoco - setting transaction isolation level

我是研究僧i 提交于 2019-12-10 13:08:55
问题 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<NewObject>("SELECT * FROM tblNewObject WHERE Id = @0", newObjectId); scope.Complete(); } While this is great for managing when in a transaction updates get committed, it's a little lacking for controlling the isolation level of a transaction similar to how you'd do it with a

PetaPoco insert fails on table with trigger

旧街凉风 提交于 2019-12-08 16:44:05
问题 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 'the_table_with_a_trigger' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause. How can we use PetaPoco to insert/update data on a table that has a trigger? 回答1: Thanks to @Eduardo Molteni,

PetaPoco update just modified records in winforms

▼魔方 西西 提交于 2019-12-08 13:15:14
问题 I have this code : namespace PetaPocoTest { public partial class Form1 : Form { PetaPoco.Database db = new PetaPoco.Database("PgConnection"); IEnumerable<customers> allCustomers; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { allCustomers = db.Query<customers>("SELECT * FROM customers"); mGrid.DataSource = allCustomers .ToList(); } private void saveButton_Click(object sender, EventArgs e) { foreach (var a in allCustomers) { db.Save("customers",

Correct way to use PetaPoco in DAL layer (ASP.NET Web Forms VB.NET)

一曲冷凌霜 提交于 2019-12-08 06:22:37
问题 I'm trying to generate my DAL layer for ASP.NET web forms project using PetaPoco. Namespace Eva.Dal.Polls Public Partial Class EVAMOD_PL_CategoryDb Private db As Eva.Dal.Core.EvaDb Public Function Insert(a As EVAMOD_PL_Category) As Object Return db.Insert(a) End Function Public Sub New() db = New Eva.Dal.Core.EvaDb End Sub End Class Public Partial Class EVAMOD_PL_GL_CategoryDb Private db As Eva.Dal.Core.EvaDb Public Function Insert(a As EVAMOD_PL_GL_Category) As Object Return db.Insert(a) End

How to use Npoco FetchOneToMany?

安稳与你 提交于 2019-12-07 17:55:35
问题 I am trying to use Npoco but running into some problems with FetchOneToMany I have a sql statement that joins 2 tables together and I output all the columns. [TableName("TableA")] [PrimaryKey("Id")] public class TableA { public int Id { get; set; } public DateTime EffectiveDate { get; set; } public IList<TableB> TableBs { get; set; } } [TableName("TableB")] [PrimaryKey("TableBId")] public class TableB { public int TableBId { get; set; } public int SomeNumber { get; set; } public int Id { get;

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

╄→尐↘猪︶ㄣ 提交于 2019-12-07 08:10:39
问题 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 = db.SingleOrDefault<Category>(sql); I get the following error: Npgsql.NpgsqlException 42883: operator does not exist: timestamp without time zone = text I understand the error message is saying I'm trying to compare a timestamp (date) with a text, however for

Should the PetaPoco database class be created once per request or every time it is needed?

天涯浪子 提交于 2019-12-07 07:03:20
问题 With PetaPoco, how should I handle the creation of the Database class? My application will probably be making use of various repositories (not quite the DDD repository, more like a gateway repository) to encapsulate the queries. Since I'll have multiple repositories that need to access the same database connection, I was thinking of making a base class that created the Database class in the constructor and calls Dispose in its destructor, and simply call this object in all derived classes, so

PetaPOCO and more than 4 joins

微笑、不失礼 提交于 2019-12-06 13:21:46
Is petapoco capable of achieving the following : 1.Unlimited joins in one query 2.Unlimited One to Many relations in one query I have looked at PetaPOCO and it seems like it is not capable of doing more than 4 joins, the longest signature looks like : db.Query<T1, T2, T3 , T4> Also seems like it supports a one to many relation , but only for one composite object such as below : db.FetchOneToMany<T1, T2> where T2 is a foreign key of T1 I'm testing some of the micro ORMs out there to stick to the best one. Do you know of any of them that can handle these situations and if none of the micro ORMs

Should the PetaPoco database class be created once per request or every time it is needed?

徘徊边缘 提交于 2019-12-05 14:11:55
With PetaPoco, how should I handle the creation of the Database class? My application will probably be making use of various repositories (not quite the DDD repository, more like a gateway repository) to encapsulate the queries. Since I'll have multiple repositories that need to access the same database connection, I was thinking of making a base class that created the Database class in the constructor and calls Dispose in its destructor, and simply call this object in all derived classes, so I think I would not need a using block in this scenario (since when the class goes out of scope it