实体框架中有许多人无法获得相关数据

时间:2016-01-18 02:21:51

标签: c# entity-framework entity

尝试从多个表中获取集合而没有运气。 目前有3个表。我不确定如何到达每个作业的SkillPool_lookup.skillname。

我目前有。

 using(Entities dbCtx = new Entities())
       {
           this.JobList = dbCtx.Jobs.Where(x => x.JobStatusId == 1)
            .Include(x => x.JobStatus_Lookup)
            .Include(x => x.Budget_Lookup)
            .Include(x => x.JobCategories_Lookup)
            .Include(x => x.JobType_Lookup)
            .Include(x => x.Job_SubCategories_Lookup)
            .Include(x => x.TimeLine_Lookup)
            .Include(x => x.RequiredJobSkills)
            .OrderByDescending(x => x.DateCreated)
            .ToList();


        }

但是Requirejobskills.skillpool_lookup总是为空???卡住。请帮忙。

public Job()
        {
            this.RequiredJobSkills = new HashSet<RequiredJobSkill>();
            this.JobReporteds = new HashSet<JobReported>();
            this.JobsEmaileds = new HashSet<JobsEmailed>();
            this.JobsSaveds = new HashSet<JobsSaved>();
        }

        public int Id { get; set; }
        public string Description { get; set; }
        public string UserId { get; set; }
        public int QuoteCount { get; set; }
        public int BudgetAmountId { get; set; }
        public int MaxBidCount { get; set; }
        public int JobCategoryId { get; set; }
        public int JobStatusId { get; set; }
        public System.DateTime DateCreated { get; set; }
        public int JobCategorySubCatId { get; set; }
        public int JobTypeId { get; set; }
        public string Title { get; set; }
        public int QuoteCountryOfOrginId { get; set; }
        public Nullable<System.DateTime> DateFilled { get; set; }
        public Nullable<System.DateTime> DateCanceled { get; set; }
        public Nullable<System.DateTime> DateCompleted { get; set; }
        public int TimeLineId { get; set; }
        public Nullable<System.Guid> UserIdentifier { get; set; }
        public System.Guid JobIdentifier { get; set; }
        public Nullable<int> UnseenQuotesCount { get; set; }
        public Nullable<int> UnseenMessagesCount { get; set; }

        public  Budget_Lookup Budget_Lookup { get; set; }
        public  Job_SubCategories_Lookup Job_SubCategories_Lookup { get; set; }
        public  JobCategories_Lookup JobCategories_Lookup { get; set; }
        public  JobStatus_Lookup JobStatus_Lookup { get; set; }
        public  JobType_Lookup JobType_Lookup { get; set; }
        public  TimeLine_Lookup TimeLine_Lookup { get; set; }
        public  ICollection<RequiredJobSkill> RequiredJobSkills { get; set; }
        public  ICollection<JobReported> JobReporteds { get; set; }
        public  ICollection<JobsEmailed> JobsEmaileds { get; set; }

        public  ICollection<JobsSaved> JobsSaveds { get; set; }
    }

 public partial class RequiredJobSkill
    {
        public int Id { get; set; }
        public int SkillId { get; set; }
        public int JobId { get; set; }
        public  Job Job { get; set; }
        public  SkillPool_lookup SkillPool_lookup { get; set; }
    }

public partial class SkillPool_lookup
    {
        public SkillPool_lookup()
        {
            this.UserSkills = new HashSet<UserSkill>();
            this.RequiredJobSkills = new HashSet<RequiredJobSkill>();
        }

        public int Id { get; set; }
        public string SkillName { get; set; }
        public string Description { get; set; }
        public  ICollection<UserSkill> UserSkills { get; set; }
        public  ICollection<RequiredJobSkill> RequiredJobSkills { get; set; }
    }

0 个答案:

没有答案