rdlc #error,不知道为什么

时间:2014-06-20 06:05:53

标签: reporting-services nested reportviewer rdlc

我有一个报告,其中显示一些子类值。它对某些人来说效果很好,但对其他人来说并不好,我不知道为什么。模特:

[Serializable]
public partial class CompanyProvider
{

    public int CompanyProviderId { get; set; }
    public string CompanyNo { get; set; }
    public string LPID { get; set; }
    public string VATNo { get; set; }

    public int? CompanyProviderAddressId { get; set; }
    [ForeignKey("CompanyProviderAddressId")]
    public virtual CompanyProviderAddress CompanyProviderAddress { get; set; }       

    public int? CompanyProviderAddressBillingId { get; set; }
    [ForeignKey("CompanyProviderAddressBillingId")]
    public virtual CompanyProviderAddressBilling CompanyProviderAddressBilling { get; set; }

    public int? CompanyProviderContactManagerId { get; set; }
    [ForeignKey("CompanyProviderContactManagerId")]
    public virtual CompanyProviderContactManager CompanyProviderContactManager { get; set; }

    public int? CompanyProviderBankId { get; set; }
    [ForeignKey("CompanyProviderBankId")]
    public virtual CompanyProviderBank CompanyProviderBank { get; set; }
   ...
}

[Serializable]
public partial class CompanyProviderBank
{
    public int CompanyProviderBankId { get; set; }

    public int? BankId { get; set; }
    public virtual Bank Bank { get; set; }

    public string Postcode { get; set; }
    public string AddressLine1 { get; set; }
    public string AddressLine2 { get; set; }
    public string City { get; set; }
}

[Serializable]
public partial class CompanyProviderAddress
{
    public int CompanyProviderAddressId { get; set; }
    public string Postcode { get; set; }
    public string AddressLine1 { get; set; }
    public string AddressLine2 { get; set; }
    public string City { get; set; }
}

它适用于只有“简单”属性(string,int ...)的CompanyProviderAddress和CompanyProviderAddress,但它不适用于具有复杂属性的CompanyProviderContactManager和CompanyProviderBank(如Bank for CompanyProviderBank)。 一切都是可序列化的,这在我的报告中有效:

=First(Fields!CompanyProviderAddress.Value.City(), "CompPro")

但是这不起作用,给我一个#Error

=First(Fields!CompanyProviderBank.Value.City(), "CompPro")

有什么想法吗?或者也许有人知道如何获得有关#error的更多细节,更明确的是什么? THX

1 个答案:

答案 0 :(得分:0)

您的对象可能是null。 您可以检查它们是否为空:

=IIF(IsNothing(First(Fields!CompanyProviderBank.Value.City)), 0,First(Fields!CompanyProviderBank.Value.City))

我不完全确定上面的语法是否正确,如果不是,请告诉我。