示例#1
0
        private static void FindApplicantByJob(DaniContext ctx)
        {
            var jobId = 2;

            var applicants = ctx.JobListings.Where(p => p.JobID == jobId).SelectMany(x => x.Applicants);

            Console.WriteLine(String.Join(",", applicants.Select(p => p.Name)));
        }
示例#2
0
        public static void Main(string[] args)
        {
            using (var ctx = new DaniContext())
            {
                var savedApplicants = ctx.Applicants.Count();
                Console.WriteLine(savedApplicants);

                AddApplicantWithJobs(ctx);

                FindApplicantByJob(ctx);
            }
        }
示例#3
0
        private static void AddApplicantWithJobs(DaniContext ctx)
        {
            var applicant = new Applicant
            {
                Name = "Steven van der Merwe"
            };

            var jobListing1 = new JobListing {
                JobTitle = "Job1"
            };
            var jobListing2 = new JobListing {
                JobTitle = "Job2"
            };

            applicant.JobListings.Add(jobListing1);
            applicant.JobListings.Add(jobListing2);

            ctx.Applicants.Add(applicant);
            ctx.SaveChanges();
        }