Copied to clipboard

Flag this post as spam?

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


  • Carl S 7 posts 87 karma points
    May 16, 2017 @ 10:39
    Carl S
    0

    Custom database table and referencing member table

    I want to create a custom datatable and reference member id as a ForeignKey - But when I do like below I get an Null reference on ForeignKey-attribute (Umbraco.Core.Models.Member) .

    I've "googled" and searched this forum but can't find any relevant answer.

    Which type must I use in the attribute?

    [TableName(DatabaseTables.Order)]
    [PrimaryKey(nameof(OrderId), autoIncrement = true)]
    [ExplicitColumns]
    public class OrderTable
    {   
        [Column(nameof(OrderId))]
        [PrimaryKeyColumn(AutoIncrement = true, Clustered = true, IdentitySeed = 1)]
        public int OrderId { get; set; }
    
        [Column(nameof(MemberId))]
        [ForeignKey(typeof(Member), Column = nameof(Member.Id))]
        public int MemberId { get; set; }
    
        [Column(nameof(CreatedDate))]
        public DateTime CreatedDate { get; set; }
    }
    
  • David Brendel 792 posts 2968 karma points MVP 2x c-trib
    May 16, 2017 @ 10:46
    David Brendel
    100

    Hi Carl,

    not sure that it is possible at all to reference Umbraco internals like content or members like this.

    Think the best way would be to just save the id and then fetch the member using the umbraco services.

    At least this is how I done it when I needed references to something like member.

    Regards David

  • Carl S 7 posts 87 karma points
    May 16, 2017 @ 11:27
    Carl S
    0

    Hi David,

    Ah that's too bad you have do to it that way. But I do understand it too.

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft