0

在下面的代码中,我尝试将 添加AttributeValueInfoEntityAttributeValueExportList,但是它没有ArticleAttributeExportLarge在我放入//largeExportList.AttributeExportList代码的位置显示为对象的属性。

我做错了什么,还是我错过了 C# 中的重要嵌套规则?

public partial class Export_Articles_Default : System.Web.UI.Page
{       
    protected void Page_Load(object sender, EventArgs e)
    {
            ArticleInfoEntity[] articleInfoList = ArticleInfoFactory.Instance.ListInfo(244);
            List<ArticleExportLarge> list = new List<ArticleExportLarge>();

            foreach (ArticleInfoEntity aie in articleInfoList)
            {
                ArticleExportLarge largeExportList = new ArticleExportLarge(aie);
                largeExportList.AttributeExportList = new List<ArticleAttributeExportLarge>();

                List<AttributeInfoEntity> attributeInfoList = AttributeInfoFactory.Instance.ListByArticle(aie.ArticleId);


                foreach (AttributeInfoEntity attributeInfo in attributeInfoList)
                {
                    largeExportList.AttributeExportList.Add(new ArticleAttributeExportLarge(attributeInfo));
                    List<AttributeValueInfoEntity> ArticleValueInfoList = AttributeValueInfoFactory.Instance.ListByArticleAndAttribute(aie.ArticleId, attributeInfo.AttributeId);

                    foreach (AttributeValueInfoEntity avie in ArticleValueInfoList)
                    {
                       //largeExportList.AttributeExportList
                    }
                }

                list.Add(largeExportList);
            }   
        }
}

public class ArticleExportLarge
{
    private ArticleInfoEntity articleInfo;
    private List<ArticleAttributeExportLarge> attributeExportList;

    public ArticleExportLarge(ArticleInfoEntity articleInfo)
    {
        this.articleInfo = articleInfo;
    }

    [XmlElement(ElementName = "attributeList")]
    public List<ArticleAttributeExportLarge> AttributeExportList
    {
        get { return attributeExportList; }
        set { attributeExportList = value; }
    }

}

public class ArticleAttributeExportLarge
    {
        private AttributeInfoEntity attributeInfo;
        private List<ArticleAttributeValueExportLarge> attributeValueExportList;

        public ArticleAttributeExportLarge(AttributeInfoEntity attributeInfo)
        {
            this.attributeInfo = attributeInfo;
        }

        [XmlElement(ElementName = "attributeValueList")]
        public List<ArticleAttributeValueExportLarge> AttributeValueExportList
        {
            get { return attributeValueExportList; }
            set { attributeValueExportList = value; }
        }
    }

public class ArticleAttributeValueExportLarge
{
    private AttributeValueInfoEntity attributeValueExportEntity;

    public AttributeValueInfoEntity AttributeValueExportEntity
    {
        get { return attributeValueExportEntity; }
        set { this.attributeValueExportEntity = value; }
    }

}
4

1 回答 1

0

我发现了我的错误。largeExportList.AttributeExportList如果我想访问该列表中的对象,我需要遍历二级列表。

于 2013-06-15T17:55:27.287 回答