SetRelatedEntity

Posts   
 
    
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 26-Oct-2007 19:18:16   

Should entity.SetRelatedEntity set the relations in both directions?

So SetRelatedEntity from Order => Customer means that the Customer.Orders collection now contains that order? (Edit: This originally said "NOT contains that order"--typo).

I would have sworn that I've done it before and it worked, but now I can't see the entity in the collection. Should I be using SetRelatedEntityProperty?

Version 2.5.07.0924, adapter vs. SQL Server 2005.

Thanks,

Phil

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Oct-2007 04:45:37   

Hi Phil,

Could you please post some code snippet where you are trying to set it up?

Also, what are you using SetRelated Entity instead of use the common entity properties?

David Elizondo | LLBLGen Support Team
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 28-Oct-2007 16:42:59   

daelmo wrote:

Hi Phil,

Could you please post some code snippet where you are trying to set it up?

Also, what are you using SetRelated Entity instead of use the common entity properties?

I will have to touch base with the developer as to why we can't use the property directly. He only sent me a test case with SetRelatedEntity.

In general, are SetRelatedEntity and SetRelatedEntityProperty not intended for use outside of the generated code?

Customer => Site is 1:m.


            //test1: use property (works)
            CustomerEntity customer = new CustomerEntity();
            SiteEntity site = new SiteEntity();         
            site.Customer = customer;
            MessageBox.Show(customer.Site.Count.ToString());

            //test2: use SetRelatedEntity (doesn't work)
            CustomerEntity customer2 = new CustomerEntity();
            SiteEntity site2 = new SiteEntity();
            site2.SetRelatedEntity(customer2, "Customer");
            MessageBox.Show(customer2.Site.Count.ToString());

            //test3: use SetRelatedEntityProperty (works)
            CustomerEntity customer3 = new CustomerEntity();
            SiteEntity site3 = new SiteEntity();
            site3.SetRelatedEntityProperty("Customer", customer3);
            MessageBox.Show(customer3.Site.Count.ToString());

Thanks,

Phil

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Oct-2007 04:41:39   

Seeing the Reference Manual, seems to me that SetRelatedEntityProperty is a better choice. However those methods are used internally by LLBLGen and I can't found any customer asking to use such methods. If you could explain the scenario maybe we could give a wiser advise.

Regards,

David Elizondo | LLBLGen Support Team