0

I have two class for my EF code first site and I can use lazyloding to go from the class Section_Translation to the class Section (i.e. Section_Translations.Section.XXXX) but I can not go from Section to Section_Translation (i.e. Section.Section_Translation.XXXX) and i am not sure what i would need to do to allow me to travel from Section to Section_Translation.

Section.cs

using FFInfo.DAL.GeneralTranslationTables;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FFInfo.DAL.GeneralTables
{
    [Table("Section")]
    public class Section
    {
        [Key, Required, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public Int16 SectionID { get; set; }

        public Int64? LogoFileID { get; set; }

        [Required, MaxLength(15), Column(TypeName = "varchar")]
        public string RouteName { get; set; }

        [Required, MaxLength(15), Column(TypeName = "varchar")]
        public string SectionType { get; set; }

        public virtual IList<Section_Translation> SectionTranslations { get; set; }

        [ForeignKey("LogoFileID")]
        public virtual File File { get; set; }
    }
}

Section_Translation.cs

using FFInfo.DAL.GeneralTables;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FFInfo.DAL.GeneralTranslationTables
{
    [Table("SectionTranslation")]
    public class Section_Translation
    {
        [Key, Required, Column(Order = 0)]
        public Int16 SectionID { get; set; }

        [Key, Required, Column(Order = 1)]
        public byte CultureCodeID { get; set; }

        [Required]
        public string SectionTitle { get; set; }

        public string Synopsis { get; set; }

        [ForeignKey("SectionID")]
        public virtual Section Section { get; set; }

        [ForeignKey("CultureID")]
        public virtual CultureCode Culture { get; set; }
    }
}
4

1 回答 1

0

与同事交谈,似乎 EF 不允许像我想要的那样构建延迟加载。

于 2013-05-07T14:20:22.920 回答