petapoco

Using PetaPoco in Asp.NET Core MVC 6

天大地大妈咪最大 提交于 2020-01-07 03:40:13
问题 so i started trying out the new ASP.NET 5 Platform and have the following dependencies in my Project.json "dependencies": { "System.Collections": "4.0.10-beta-23019", "System.Linq": "4.0.0-beta-23019", "System.Threading": "4.0.10-beta-23019", "System.Runtime": "4.0.10-beta-23019", "Microsoft.CSharp": "4.0.0-beta-23019", "PetaPoco.Core": "5.1.141-beta" }, "frameworks": { "dnx451": { "dependencies": { "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5" } }, "dnxcore50": { "dependencies":

Peta POCO like query issue

妖精的绣舞 提交于 2019-12-25 00:15:52
问题 I am using Micro ORM PetaPOCO, and I want to use like query, i am getting exception, please help me if any one know. var context = new PetaPoco.Database(Connection.connectionstring); SqlQuery = @"SELECT CmsPage.PageId, CmsPage.PageTitle, CmsPage.MenuId, CmsPage.PageDescription, CmsPage.Title, CmsPage.MetaKeyword, CmsPage.MetaDescription, CmsPage.CreatedDate, CmsPage.IsActive FROM ( SELECT ROW_NUMBER() OVER (ORDER BY CmsPage.PageTitle) AS row, CmsPage.PageId, CmsPage.PageTitle, CmsPage.MenuId,

Peta Poco where clause

余生颓废 提交于 2019-12-24 14:15:33
问题 I am trying to do this in petapoco var people = db.Query<Person>("SELECT * FROM people").Where(p => p.FirstName.Equals("George") && p.LastName.Equals("Clooney")).ToList(); the problem is that it gets the entire set of records from the database and then performs the filtration on it. I tried Fetch instead of query, same result. How do I write the query so that it sends the query to get the filtered results from the database, instead of doing the filtering at the webserver? 回答1: var people = db

Set default datetime value with PetaPoco

半世苍凉 提交于 2019-12-24 11:34:59
问题 I have a PetaPoco class which defines a database table. It looks like this: namespace MyProject.Pocos { [TableName("AdminNotification")] [PrimaryKey("id", autoIncrement = true)] [ExplicitColumns] public class AdminNotification { [Column("id")] [PrimaryKeyColumn(AutoIncrement = true)] public int id { get; set; } [Column("dateTime")] public DateTime dateTime { get; set; } [Column("adminNotificationTypeId")] public int adminNotificationTypeId { get; set; } } } It works great except for one thing

How to map childs/parent class with petapoco?

北城余情 提交于 2019-12-24 06:25:37
问题 I have these classes: class Car { int ID; string Name; } class Truck : Car { int MaximumLoad; } I have these tables Car - ID - Name Truck - CarID - MaximumLoad How could I map my classes with my table using PetaPoco ? 回答1: If you store Car and Truck in the same table (TPH) you can inherit Truck from Car with minor changes to PetaPOCO source code, table Vehicle (ID, Discriminator, Name, MaximumLoad) in PetaPOCO.cs, add [AttributeUsage(AttributeTargets.Class)] public class

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

淺唱寂寞╮ 提交于 2019-12-23 17:30:05
问题 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<EntryImage>().Where(t => t.EntryType == type && t.EntryID == entryID); B : Query<EntryImage>().Where(t => t.EntryType == type && t.EntryID == entryID); A returns every row in the table (10,000+) and then filters client side. B returns just the one row I'm expecting. I find this

PetaPoco query with typed parameters

左心房为你撑大大i 提交于 2019-12-23 11:58:28
问题 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; 回答1: Check out the documentation for further details but here is an extract. http://www.toptensoftware.com/Articles/114/PetaPoco-What-s-new-in-v4-0 Support for IDbParameters as SQL arguments PetaPoco now supports directly passing IDbParameter objects to a query. This is handy if PetaPoco doesn't correctly map a property. For example the

How to check a var for null value?

∥☆過路亽.° 提交于 2019-12-23 07:01:28
问题 I am using PetaPoco Micro-ORM with C# 4.0. The code below retrieves a single row from the database: var result = db.SingleOrDefault<TdUsers>(getUserQuery); I would like to check whether or not the result contains any rows, and whether is null. What is the best way to do this? 回答1: if (result == null || result.Count() == 0) { // Checks whether the entire result is null OR // contains no resulting records. } I think the problem is not in your check for null , because linq is lazy loading. Your

PetaPOCO and more than 4 joins

牧云@^-^@ 提交于 2019-12-22 19:49:45
问题 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

PetaPoco stored procedure error “Incorrect syntax near the keyword 'FROM'.”}

纵然是瞬间 提交于 2019-12-22 16:43:11
问题 I'm using C# with TSQL and SQL Server 2005 I'm trying to use PetaPoco to return a dataset as a list of objects. this is the code I'm using just now var s = PetaPoco.Sql.Builder.Append("USE [BI] EXEC [dbo].[TestProcedure2];"); var result = db.Query<dynamic>(s); var result2 = db.Query<dynamic>("USE [BI] EXEC [dbo].[TestProcedure2];"); I think the error message is a generic sql error for when petaPoco fails. At first I was using a stored procedure with paramaters and the @ character was causing