Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
Need some help on this problem that have bedevil my work for the late two days.
I'm developing an application using the EF 4.3 w/ DbContext DbSet, created three entities Taxpayer TaxType and EconomicActivity
there are one-to many relationships betwwen Taxpayer TaxType on the one hand and Taxpyer EconomicActivity on the other. using a foriegn key TaxpayerID created a navigiation properties TaxTypes and EconomicActivities as part of the taxpayer entity. I created a UI with winform which consisted of textboxes, comboboxes and others for the Taxpayer entity that is working very well. For the navigation properties EconomicActivies and TaxTypes, the user requirement is that all the details are list in a datagridview and there should have textboxes and other controls to edit and add new details info for taxtypes and EconomicActivities. I added these controls and bind them and the datagridview using bindingsource component and notice that when there are already existing taxtypes the form loads successfullyand the user can add more taxtypes, the same for economicActivities too. However, when there is no record existing for the taxtype and the user try loading the form during the binding of the bindingsource to the controls apart from the datagridview it gives and error
"Cannot bind to the property or column of the Datasource Parameter: datamember.
below is the linq query to load the data for the taxpayer and their respective taxtypes and EconomicActivities

SQL
_ctx.TaxPayerInitialCorporates.Include("EconomicActivities").Include("TaxTypes).Load()

A workarround I'm doing is to clear the binding from all the controls when navigation property count is zero and set a flag and where the user when to add new rebinding each control after creating new taxtype entity on request to add new, which I think is not the best solution
Your help will be very muc apprieciated
Posted
Updated 5-Jun-12 11:24am
v2

1 solution

With the help of info from other forum I was able to sort the issue out. the problem is because the default navigation property in EF 4.3 DbContext is HashSet instead of ObservableListSource and thus it is set the new List
Information for the solution is thank to the Guest from the link below

http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/1d137a8c-d4bb-40fd-9a25-35e00c74bb85#2ec9d185-9fb2-4026-876b-8e406304f3a3[^]

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900