问题
I am trying to bind to the results of a Linq-To-SQL query, which I have set to populate a graph.
The graph is along the lines of Date along the X-Axis and Money along the Y-Axis. There are two-series, one for money in, and one for money out.
Simple enough so far.
I wanted to add a third series which is "balance of trade", i.e. the difference between income and outgoing. I created a partial class for this, which uses the fields in the generated code in order to calculate the correct figure.
All goes well until I try to bind this to my graph. The calculated properties do not appear at all within the Binding Source drop down box within visual studio...all of the other Properties (i.e. the ones not in the partial) work fine.
I have tested that my partial works and has the correct namespace - I can manually do tests proving it works, the problem is simply that VS doesn't appear to see the properties I have added using the partial.
Edit: In addition, I have also made sure the properties are public.
Any ideas?
回答1:
As Tobias suggested, I have added the binding manually, which seems to work fine.
It seems it is Visual Studio's member resolution which is to blame. Interestingly if the data objects are in a different assembly there is no problem, I guess due to the way VS resolves classes from different assemblies.
来源:https://stackoverflow.com/questions/9133349/bindingsource-doesnt-appear-to-contain-properties-created-in-partial-class