在撰写评论

时间:2018-02-23 21:18:09

标签: c# sql .net postgresql entity-framework

想要创建一个评论表,并对我需要放置哪些外键感到困惑。我希望 ONE 用户能够在 SECOND 用户页面上留下评论。这是我目前的模特。我需要在那里添加什么?

评论

using System;
using System.Collections.Generic;

namespace sellwalker.Models
{
    public class Review : BaseEntity
    {
        public int ReviewId{get;set;}
        public string Content{get;set;}
        public DateTime CreatedAt{get;set;}
        public int UserId{get;set;}
        public User Reviewer {get;set;}


    }
}

用户

using System;
using System.Collections.Generic;

namespace sellwalker.Models
{
    public class User : BaseEntity
    {   

        public int UserId{get;set;}
        public string FirstName{get;set;}
        public string LastName{get;set;}
        public string Email{get;set;}
        public string Password{get;set;}
        public string Status{get;set;}
        public string ProfilePic {get;set;}

        public List<Order> Orders {get;set;}
        public List<Product> products {get;set;}
        public List<Review> Reviews {get;set;}
        public User()
        {
            Orders = new List<Order>();
            products = new List<Product>();
            Reviews = new List<Review>();
        }
    }
}

使用当前表我可以写评论,但我想将其链接到特殊用户。系统不允许我再添加一个UserId,那么这里最好的解决方案是什么?

0 个答案:

没有答案
相关问题