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 157 posts 385 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 1593 posts 7151 karma points MVP 6x 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 157 posts 385 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 ?

Please Sign in or register to post replies

Write your reply to:

Draft