0
public class JobDescription
    {
        public int JobDescriptionID { get; set; }

        //          

        public virtual List<Image> Image { get; set; }

    }

 public class Image
    {
        public int ImageID { get; set; }

        [Required]
        public int JobDescriptionID { get; set; }

        [ForeignKey("JobDescriptionID")]
        public virtual JobDescription JobDescription { get; set; }

        public virtual List<ImageSection> ImageSection { get; set; }
    }

 public class ImageSection
    {
        public int ImageSectionID { get; set; }

        //
        public int ImageID { get; set; }

        [ForeignKey("ImageID")]
        public virtual Image Image { get; set; }

        public virtual DigitalSection DigitalSection { get; set; }

    }

public class DigitalSection
    {
        public int DigitalSectionID { get; set; }

         public int ImageSectionID { get; set; }

         [ForeignKey("ImageSectionID")]
         public virtual ImageSection ImageSection { get; set; }

         public virtual VerifiedSection VerifiedSection { get; set; }
    }

public class VerifiedSection
    {
        public int VerifiedSectionID { get; set; }


        public string DigitizedText { get; set; }


        public int DigitalSectionID { get; set; }

        [ForeignKey("DigitalSectionID")]
        public virtual DigitalSection DigitalSection { get; set; }

    }

私は CodeFirst アプローチを使用していJobDscriptionIDます。DigitizedText今、テーブルからすべてを撤回したいと思いますVerifiedSection。どうやってするの ?

4

2 に答える 2

1

これを試して :

var result = contetx.VerifiedSection
            .Where(V => V.DigitalSection.ImageSection.Image.JobDescription.JobDescriptionID == 1)
            .Select(V => V.DigitizedText);

または、 Join を使用することもできます

var result = context.VerifiedSection.Join(context.DigitalSection.Join(
                    (context.ImageSection.Join
                    (context.Image.Join
                    (context.JobDescription.Where(J=> .JobDescriptionID == 1)), I=> I.JobDescriptionID, J => J.JobDescriptionID , (I,J) => I)
                    IS => IS.ImageID, I=> I.ImageID, (IS,I) => IS)
                    D => D.ImageSectionID, IS => IS.ImageSectionID , (D,IS) => D)
                    V => V.DigitalSectionID, D => D.DigitalSectionID, (V,D) => V.DigitizedText);

幸運を !!

于 2012-09-30T05:12:44.847 に答える
0
var query = (from image in Context.Image 
            Where image.JobDescriptionID == id
            select image.ImageID).SingleOrDefault();

var query2 = (from select in Context.ImageSection 
            Where select.ImageID == query
            select select.ImageSectionID).SingleOrDefault();

var query3 = (from digital in Context.DigitalSection 
                Where digital.ImageSectionID == query2
                select digital.DigitalSectionID).SingleOrDefault();

var query4 = from text in Context.VerifiedSection 
            Where text.VerifiedSection == query3
            select select.DigitizedText;

Kundan Singh Chouhan がより良い回答を提供してくれましたが、おそらく「クエリ」の方法でやりたいと思うでしょう。

于 2012-09-30T07:48:09.273 に答える