【问题标题】:Referenced properties of generated custom entites class doesn't work生成的自定义实体类的引用属性不起作用
【发布时间】:2013-04-18 12:58:14
【问题描述】:

我用CRM Devtoolkit 生成了类。 通过OrganizationServiceContext.CreateQuer<customEntityType>().Where(someExpression).FirstOfDefault() 获得任何实体。结果很好。 Is 具有所有自己的属性,但相关的实体:

    /// <summary>
    /// N:N inv_inv_templatedelivery_account
    /// </summary>
    [Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("relashionshipname")]
    public System.Collections.Generic.IEnumerable<CustomEntity> inv_inv_templatedelivery_account
    {
        get
        {
            return this.GetRelatedEntities<CustomEntity>("relashionshipname", null);
        }
        set
        {
            this.OnPropertyChanging("somePointer");
            this.SetRelatedEntities<CustomEntity>("relashionshipname", null, value);
            this.OnPropertyChanged("somePointer");
        }
    }

此代码由 SDK Developer Toolkit 生成! 为什么它返回NULL???? 我还尝试使用 CrmSvcUtil.exe 生成类 - 结果相同。

非常感谢。

【问题讨论】:

    标签: dynamics-crm-2011 dynamics-crm


    【解决方案1】:

    您必须使用 contact.LoadProeprty 方法实际强制加载这些相关属性:

    context.LoadProperty(entity, "inv_inv_templatedelivery_account");

    您不希望 CRM 每次都拉回所有相关项目的所有数据,因此您必须每次指定要加载的内容。

    【讨论】:

    • 谢谢,很有用!但是 LoadProperty 只允许从 this.GetRelatedEntities("relashionshipname", null) 返回数据。这与 Lasy Loading 无关
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-03
    • 1970-01-01
    • 2017-11-14
    • 1970-01-01
    • 1970-01-01
    • 2016-10-13
    相关资源
    最近更新 更多