绑定到实体框架(WPF C#)中存储过程的ComplexType结果

绑定到实体框架(WPF C#)中存储过程的ComplexType结果,c#,entity-framework,entity-framework-4,complextype,C#,Entity Framework,Entity Framework 4,Complextype,可能重复: 我需要将存储过程的输出(我认为它已正确映射到复杂类型)获取到ObservableCollection中,以便使用CollectionViewSource将其绑定到列表框。我不知道还能尝试什么 我的代码现在看起来就像这样: private void Window_Loaded(object sender, RoutedEventArgs e) { CollectionViewSource GetParts_ResultViewSource = ((

可能重复:

我需要将存储过程的输出(我认为它已正确映射到复杂类型)获取到ObservableCollection中,以便使用CollectionViewSource将其绑定到列表框。我不知道还能尝试什么

我的代码现在看起来就像这样:

    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);
                      }
              }
       }
      }
但它是被提供的……或者我是这么认为的……并且作为int,这是我的存储过程所期望的


好的,我在这里尝试使用selectedPartShape.attributeID和null参数来测试我的函数映射,因为我的存储过程接受两个输入值,其中所有值都可以为null

最后,我将使用另一个listbox.SelectedValue属性作为第二个输入参数


我想我也可以手动输入一些相同的整数类型ID(例如:this.myEntities.GetParts(5161))来返回一个零件号列表,每个零件号都具有这些ID的属性。

假设
this.myEntities.GetParts(selectedPartShape.attributeID,null)
被映射到存储过程,我最好的猜测是,由于null参数,您得到了错误。AttributeView是可空的还是可空的int?字段?

另外,忘了提到根据Intellisense,我的存储过程接收int?作为输入,而AttributeView.attri但是EID不可为null,这在这里似乎无关紧要,因为我已经尝试使用已知的整数值作为输入参数在SQL中返回结果。
 "{"Procedure or function 'GetParts' expects parameter '@@partShape', which was not supplied."}"