Copied to clipboard

Flag this post as spam?

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


  • Mus'ab 158 posts 387 karma points notactivated
    Oct 10, 2019 @ 08:16
    Mus'ab
    0

    How to use a custom database table to store likes and views ?

    Hi our

    i have this class code

    [System.Web.DynamicData.TableName("BlogLikesViews")]
    [PrimaryKey("BlogNewsId", AutoIncrement = true)]
    [ExplicitColumns]
    public class BlogComment
    {
        [Column("id")]
        [PrimaryKeyColumn(AutoIncrement = true)]
        public int BlogNewsId { get; set; }
    
        [Column("BlogNewsUmbracoId")]
        public int BlogNewsUmbracoId { get; set; }
    
        [Column("Views")]
        public string Views { get; set; }
    
        [Column("Likes")]
        public string Likes { get; set; }
    }
    

    how can i create the table if not exist when the application start and how can i store the likes and views for each news node ?

  • Nik 1625 posts 7295 karma points MVP 8x c-trib
    Oct 10, 2019 @ 08:33
    Nik
    0

    Hi Mus'ab,

    You seem to have a duplicate question (Although slightly different). I've answered on there but essentially:

    https://our.umbraco.com/documentation/Extending/Database/

    ^^ This is your best guide to getting started with adding tables to the Umbraco v8 database.

    Nik

  • Mus'ab 158 posts 387 karma points notactivated
    Oct 10, 2019 @ 10:51
    Mus'ab
    0

    Hi Nik

    another question how can i execute a query on the table from the views ?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies