Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Manish 373 posts 932 karma points
    Jul 25, 2017 @ 08:25
    Manish
    0

    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

  • Johan Reitsma 67 posts 233 karma points
    Jul 25, 2017 @ 08:33
    Johan Reitsma
    0

    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

  • Manish 373 posts 932 karma points
    Jul 25, 2017 @ 08:54
    Manish
    0

    Thanks for replying me

    Do i need to install anything in version umbraco version 7 to start with ?

    Manish

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 25, 2017 @ 09:13
    Alex Skrypnyk
    0

    Hi Manish

    You have to install nothing. Peta POCO is part of the core now. Just be sure that you use this references:

    using Umbraco.Core;
    using Umbraco.Core.Persistence;
    

    Thanks,

    Alex

  • Manish 373 posts 932 karma points
    Jul 25, 2017 @ 09:16
    Manish
    0

    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

  • Johan Reitsma 67 posts 233 karma points
    Jul 25, 2017 @ 09:25
    Johan Reitsma
    101

    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/

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 25, 2017 @ 09:25
    Alex Skrypnyk
    0

    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

  • Manish 373 posts 932 karma points
    Jul 25, 2017 @ 09:27
    Manish
    0

    Hi Alex

    I want to create a page in CMS which perform CRUD operation with custom tables.

    Manish

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 25, 2017 @ 09:27
    Alex Skrypnyk
    0

    It's exactly what can do peta POCO, create table with petaPOCO and do CRUD operations with it.

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 25, 2017 @ 09:34
    Alex Skrypnyk
    1

    Table creation example:

    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; }
       }
    }
    

    Thanks,

    Alex

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 25, 2017 @ 09:34
    Alex Skrypnyk
    1

    Peta POCO uses the same connection string as Umbraco.

  • Manish 373 posts 932 karma points
    Jul 25, 2017 @ 11:21
    Manish
    0

    Thanks to all

    Now able to start :)

Please Sign in or register to post replies

Write your reply to:

Draft