ComboBox Datasource Displaymember subpath prefetch

Posts   
 
    
zee
User
Posts: 35
Joined: 24-Jul-2008
# Posted on: 05-Aug-2008 21:25:15   

Okay, now that i have important stuff in the subject....

I have a winform, talking to a WCF

I am trying to put in 3 combo boxes..

My tables

CustomerVendor AutoId VendorId --->fk, Vendor CustomerId --->fk, customer DestinationId --->fl, customer

Vendor VendorId (identify,pk) AName....

Customer CustomerId (identify,pk) AName....

in my WCF i have GetVendors..... this will get me all the vendors in Vendors and prefetch customerVendors and subpath Customer and Destination for each CustomerVendor..

does it work., yes., no issues with compiling.,

I am doing this so that just 1 call is made to the WCF... also., when the comboboxes are changed (selection)., i do not want to make another call to the WCF....

in my first dropdown., i have vendors vendor1, vendor2, vendor3.....

vhen a vendor is selected i have.,

        Dim Thecollection As VendorEntity = CustomerCollection(cmb_vendor.SelectedIndex)
        Dim acollection As IEntityCollection2 = Thecollection.CustomerAccount
        cmb_customers.DataSource = acollection
        cmb_customers.DisplayMember = "AutoId"
        'cmb_customers.ValueMember = "AutoId"
        cmb_customers.SelectedIndex = -1

This will ofcourse work., it will populate the 2nd dropdown with the AutoId values in CustomerVendor....

What i want is.... Customer.AName.... so the subpath.... child., whatever you want to call it. when i try to do that., i just get types... for example Mycomponent.EntityClasses.CustomerAccountEntity for all the values....

is there a clean and easy way to step down to the CustomerAccount.Customer.Aname?

zee
User
Posts: 35
Joined: 24-Jul-2008
# Posted on: 05-Aug-2008 21:43:23   

just an fyi...

i was playing around and was able to modify my function to

        Dim acollection As IEntityCollection2 = Thecollection.CustomerCollectionViaCustomerAccount 
        cmb_customers.DataSource = acollection
        cmb_customers.DisplayMember = "CustomerName"
        'cmb_customers.ValueMember = "CustomerId"
        cmb_customers.SelectedIndex = -1

and that got me the data that i needed for the list...

p.s. i did add Dim Customer As IPrefetchPathElement2 = path.Add(VendorEntity.PrefetchPathCustomerCollectionViaCustomerAccount)

looking at my solution now.... i dont think what i want is possible.,

i want a 1 derives 2., 2 derives 3...

from what i have so far i have 1 derrives 2 and 3....

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 06-Aug-2008 11:56:39   

Some points are not clear to me.

Dim Thecollection As VendorEntity = CustomerCollection(cmb_vendor.SelectedIndex)

What the above line is doing? I'm confused whether "TheCollection" should be a collection or an Entity, and of which type?

Dim Customer As IPrefetchPathElement2 = path.Add(VendorEntity.PrefetchPathCustomerCollectionViaCustomerAccount)

What's CustomerAccount's relation to the previously described model? Did you by any chance mean CustomerVendor instead of CustomerAccount?

i want a 1 derives 2., 2 derives 3...

from what i have so far i have 1 derrives 2 and 3....

Unclear.

zee
User
Posts: 35
Joined: 24-Jul-2008
# Posted on: 13-Aug-2008 19:40:59   

sorry that i was unclear simple_smile what i was trying to create was a combo box dependancy

there are 3 combo boxes

Vendor, Customer, Destination

Vendor has customers, customers have destination

Customers and Destination come from the same table (Customers) Vendors come from the Vendor Table.

A table CustomerAccount ties the three together, i will make up some values for CustomerAccount

ShoeMaker, Nike, Nike The above relays to, Vendor ShoeMaker, creates shoes for Nike and delivers them to Nike,. a few more examples ShoeMaker, Addias, Adidas ShoeMaker, Puma, Puma but also ShowMaker, Puma, Lama (lama is a sister brand for Puma)..

From the above list if you selected ShoeMaker in teh first combo. The second combo will display Adidas, Puma if you selected Adidas from the second combo The third will display, Adidas if you selected Puma in the second combo,. the third would display Puma, Lama

What i was trying to do, was 1 read for CustomerAccount with all the relations prefetched so that when my WCF sends back the entity, i can, in memory populate the combo boxes.

i moved away from working on this because i was able to somewhat get what i needed, i have 9 days left on the demo i am trying to the CTO to buy me a copy simple_smile

I am getting a better understanding of the applications slowly... so i will try to play it again and see if i need to post code here... and give a db schema example.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 14-Aug-2008 09:40:27   

I'd have done as follows:

Use Hashtables/Dictionaries to store collections for each combo box. And read them on the SelectedIndexChanged of the parent combo.

1st combo: loaded from the customerAccount collection Value Member = VendorId DisplayMember = Vendor.VendorName (You may have a field on a related field to better bind to this value)

2nd combo: use a Dictionary(vendorId, List<Customer>), which you should populate when you fetch the graph from the WCF.

Then on the SelectedIndexChanged on the 1st Combo, you should pick the new VendorId and load the 2nd combo with the corresponding List<Customer> from the Dictionary.

Similarly you can do the 3rd combo, where the key of the Dictionary might be complex, such as: string key = VendorId.ToString() + "_" + CustomerId.ToString();