This is my first time to use peta-poco. I don't have any idea how to use this. Is there any example for latest version which can help me to start with.
I am just beginning sample for poco but don't have idea where to start. Link provided above is bouncer to me is there any more sample which looks simple for poco beginner with more detail.
I don't know your knowledge level, but its pretty easy.
If you have an object you can map that to a database table. Columns map using attributes. Google has a lot of simple examples but you need basic level of understanding SQL and attributes.
using Umbraco.Core;
using Umbraco.Core.Persistence;
namespace MyDemo.Web.Logic.Extensions
{
public class RegisterEvents : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var db = applicationContext.DatabaseContext.Database;
if (!db.TableExist("wilCompetition"))
{
db.CreateTable(false);
}
}
}
}
POCO class:
using System;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace MyDemo.Web.Data.Poco
{
[TableName("wilCompetition")]
[PrimaryKey("Id", autoIncrement = true)]
public class Competition
{
[PrimaryKeyColumn(AutoIncrement = true)]
public int Id { get; set; }
public string Name { get; set; }
[Column("CompetitionDescription")]
[NullSetting(NullSetting = NullSettings.Null)]
[SpecialDbType(SpecialDbTypes.NTEXT)]
public string Description { get; set; }
public DateTime CreatedOn { get; set; }
}
}
How to use peta-poco
Hi
This is my first time to use peta-poco. I don't have any idea how to use this. Is there any example for latest version which can help me to start with.
Please help me on this
Manish
there are many examples you can find on the internet.
This one is an example http://www.wiliam.com.au/wiliam-blog/using-petapoco-with-umbraco-is-pretty-sweet
Thanks for replying me
Do i need to install anything in version umbraco version 7 to start with ?
Manish
Hi Manish
You have to install nothing. Peta POCO is part of the core now. Just be sure that you use this references:
Thanks,
Alex
Thanks Alex
I am just beginning sample for poco but don't have idea where to start. Link provided above is bouncer to me is there any more sample which looks simple for poco beginner with more detail.
Manish
I don't know your knowledge level, but its pretty easy.
If you have an object you can map that to a database table. Columns map using attributes. Google has a lot of simple examples but you need basic level of understanding SQL and attributes.
Here is an other example: https://creativewebspecialist.co.uk/2013/07/16/umbraco-petapoco-to-store-blog-comments/
Peta POCO is a smal ORM, it's easy to access database with peta POCO, nothing special.
What do you want to do with petaPOCO?
THanks,
Alex
Hi Alex
I want to create a page in CMS which perform CRUD operation with custom tables.
Manish
It's exactly what can do peta POCO, create table with petaPOCO and do CRUD operations with it.
Table creation example:
POCO class:
Thanks,
Alex
Peta POCO uses the same connection string as Umbraco.
Thanks to all
Now able to start :)
is working on a reply...