开发者

Access Other Entity Collections from Entity Partial Class

开发者 https://www.devze.com 2023-01-13 19:12 出处:网络
I have an entity class that has a property that contains a business code. I would like to add a property that will containthe description of that business code.开发者_运维百科To do this it will requir

I have an entity class that has a property that contains a business code. I would like to add a property that will contain the description of that business code.开发者_运维百科 To do this it will require that I query another entity collection, but the entity collection doesn't seem to be accessible in the partial class of the entity. I can't solve this with an association because the codes will not alway exist in the desciprion table.

Any ideas?


The collections and referenced entities are not available on the entity construction, so no partial methods or overrides are available for collections or referenced objects.

But...

You can simply add your partial class a Getter that will return or initiate your business logic when called as the entity is fully loaded then, and everything could be referneced as usual :

public partial class Organization
{
..
..
   public bool IsIsoCertified
    {
        get
        {
            return CheckIsoCert();
        }
    }


    private bool CheckIsoCert()
    {
        return this.CertCollection.Contains(Certifications.IsoCertification);
    }

..
..
0

精彩评论

暂无评论...
验证码 换一张
取 消