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 71 posts 242 karma points notactivated
    1 week ago
    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 1134 posts 4700 karma points MVP 2x c-trib
    1 week ago
    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 71 posts 242 karma points notactivated
    1 week ago
    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