0

私は自己参照モデルを持っています。私はlinq.iでデータを取得したいのですが、ステータスがOKのときにデータを返したいのですが、親のステータスがOKの場合、すべての子がOKまたは保留中または削除済みを返します。これどうやってするの。

var model = _efComment.List(p => p.PostId == postId);
        var list = model.ToList()
            .Where(p => p.ComentStatus == ComentStatus.Ok)
            .Where(x => x.Reply == null)
            .ToList();using System.Collections.Generic;

using System.ComponentModel.DataAnnotations.Schema;
using DomainModel.Classes;

namespace DomainModel
{
    public class Comment : BaseFieldsTables
    {
        public string Content { get; set; }
        public string WriterName { get; set; }
        public string WriterEmail { get; set; }
        public string WriterWebsite { get; set; }

        public int PostId { get; set; }

        [ForeignKey("PostId")]
        public Post Post { get; set; }

        public Comment Reply { set; get; }

        public int? ReplyId { get; set; }
        public ICollection<Comment> Children { get; set; }
        public ComentStatus ComentStatus { get; set; }
    }
}
namespace DomainModel
{
    public enum ComentStatus
    {
        Ok = 1,
        Pending = 2,
        Deleted = 3
    }
}
4

0 に答える 0