Possible Duplicate:
How to correctly invoke a function that maps a SProc to ObservableCollection in Entity Framework where Objects are of Complex Type
I need to get the output of my stored procedure (which I believe is properly mapped to a complex type ) into an ObservableCollection so that I can bind it to a ListBox using a CollectionViewSource. I don't know what else to try.
My code now looks EXACTLY like this:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
CollectionViewSource GetParts_ResultViewSource = ((CollectionViewSource)(this.FindResource("getParts_ResultViewSource");
GetPart_ResultViewSource.Source = this.selectedPnsCollection;
}
private ObservableCollection<GetParts_Result> selectedPnsCollection = new ObservableCollection<GetParts_Result>();
private void shapeAttributeLBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
AttributeView selectedPartShape = this.shapeAttributeLBox.SelectedValue as AttributeView;
if (shapeAttributeLBox.SelectedValue != null)
{
selectedPnsCollection.Clear();
foreach (GetParts_Result result in
this.myEntities.GetParts(selectedPartShape.attributeID, null));
{
selectedPnsCollection.Add(result);
}
}
}
}
However, I'm getting an inner exception that states
"{"Procedure or function 'GetParts' expects parameter '@@partShape', which was not supplied."}"
But it was supplied...or so I thought...and as an int, which is what my stored procedure expects.
well, what I'm attempting here is to use both the selectedPartShape.attributeID AND null parameters to test my function mapping since my SProc takes two input values, where all are nullable.
Eventually, I'll use another listbox.SelectedValue property as the second input parameter.
I figured I could just as well manually feed some integer-type IDs just the same (ex: this.myEntities.GetParts(5,161) to return a list of part numbers that each posses attributes with those ids.
Assuming this.myEntities.GetParts(selectedPartShape.attributeID, null)
is mapped to the stored procedure, my best guess would say you are getting the error because of the null parameter. Is the AttributeView.attributeId a Nullable<int> or int? field?