简体   繁体   中英

rdlc #error, don't know why

i have a report where i display some subclasses values. It's working well for some, but not for others and i don't know why. The models :

[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; }
}

It's working for CompanyProviderAddress and CompanyProviderAddress which have only "simple" properties (string, int...), but it doesn't work for CompanyProviderContactManager and CompanyProviderBank which have complex properties (like Bank for CompanyProviderBank). Everything is serializable, this is working in my report :

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

But this doesn't works, give me an #Error

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

Any idea? Or maybe someone knows how to get more details about #error, something more explicit? Thx

It is possible your objects are null . You can check if they are null like this:

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

I'm not entirely sure the above is in the correct syntax, please let me know if it isn't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM