Entityset Mapping错误 - EF5 - 具有多个结果集的存储过程

时间:2013-09-05 16:04:27

标签: c# entity-framework stored-procedures entity-framework-5

我的应用程序首先开始使用EF3.5进行开发,并将Model / EDMX升级到EF5。我试图使用一个返回2个结果集的存储过程。这两个结果都是查询的结果,并且没有任何具有精确列顺序的表。

我已经跟随了Microsoft article的第二部分并进行了编译。但是在运行时它会抛出错误

  

错误3027:未指定以下映射   EntitySet / AssociationSet - NotViewedReports,ViewedReports

如何使这项工作?非常感谢任何帮助

以下是此存储过程的整个映射

<EntityType Name="NotViewedReport">
          <Key>
            <PropertyRef Name="RecordID" />
          </Key>
          <Property Name="RecordID" Type="String" Nullable="false" MaxLength="240" FixedLength="false" Unicode="true" />
          <Property Name="ReportId" Type="Int32" Nullable="true" />
          <Property Name="ReportDesc" Type="String" Nullable="true" MaxLength="240" FixedLength="false" Unicode="true" />
          <Property Name="ReportLink" Type="String" Nullable="true" MaxLength="240" FixedLength="false" Unicode="true" />
          <Property Name="ReportDate" Type="DateTime" Nullable="true" Precision="3" />
          <Property Name="DistributionDate" Type="DateTime" Nullable="true" Precision="3" />
          <Property Name="ReportTypeId" Type="Int32" Nullable="true" />
          <Property Name="IsLocked" Type="Boolean" Nullable="true" />
          <Property Name="EffectiveStartDate" Type="DateTime" Nullable="true" Precision="3" />
          <Property Name="EffectiveEndDate" Type="DateTime" Nullable="true" Precision="3" />
          <Property Name="Investor_ID" Type="Int32" Nullable="true" />
          <Property Name="Investor_Name" Type="String" Nullable="true" MaxLength="100" FixedLength="false" Unicode="true" />
        </EntityType>
        <EntityType Name="ViewedReport">
          <Key>
            <PropertyRef Name="RecordID" />
          </Key>
          <Property Name="RecordID" Type="String" Nullable="false" MaxLength="240" FixedLength="false" Unicode="true" />
          <Property Name="ReportId" Type="Int32" Nullable="true" />
          <Property Name="ReportDesc" Type="String" Nullable="true" MaxLength="240" FixedLength="false" Unicode="true" />
          <Property Name="ReportLink" Type="String" Nullable="true" MaxLength="240" FixedLength="false" Unicode="true" />
          <Property Name="ReportDate" Type="DateTime" Nullable="true" Precision="3" />
          <Property Name="DistributionDate" Type="DateTime" Nullable="true" Precision="3" />
          <Property Name="Mr_Ms" Type="String" Nullable="true" MaxLength="50" FixedLength="false" Unicode="true" />
          <Property Name="Last_Name" Type="String" Nullable="true" MaxLength="50" FixedLength="false" Unicode="true" />
          <Property Name="First_MI" Type="String" Nullable="true" MaxLength="50" FixedLength="false" Unicode="true" />
          <Property Name="Company" Type="String" Nullable="true" MaxLength="255" FixedLength="false" Unicode="true" />
          <Property Name="LoginTime" Type="DateTime" Nullable="true" Precision="3" />
          <Property Name="Contact_ID" Type="Int32" Nullable="true" />
          <Property Name="LastViewed" Type="DateTime" Nullable="true" Precision="3" />
          <Property Name="Investor_Name" Type="String" Nullable="true" MaxLength="100" FixedLength="false" Unicode="true" />
        </EntityType>
    </Schema>
    </edmx:ConceptualModels>

......
<FunctionImport Name="GetBatchViewStatus">
            <Parameter Name="batchFrom" Mode="In" Type="Int32" />
            <Parameter Name="batchTo" Mode="In" Type="Int32" />
            <ReturnType EntitySet="NotViewedReports" Type="Collection(IRISModel.NotViewedReport)" />
            <ReturnType EntitySet="ViewedReports" Type="Collection(IRISModel.ViewedReport)" />
          </FunctionImport>
        </EntityContainer>

.....
<FunctionImportMapping FunctionImportName="GetBatchViewStatus" FunctionName="IRISModel.Store.GetBatchViewStatus" >
              <ResultMapping>
                <EntityTypeMapping TypeName ="IRISModel.NotViewedReport">
                  <ScalarProperty Name="RecordID" ColumnName="RecordID" />
                  <ScalarProperty Name="ReportId" ColumnName="ReportId" />
                  <ScalarProperty Name="ReportDesc" ColumnName="ReportDesc" />
                  <ScalarProperty Name="ReportLink" ColumnName="ReportLink" />
                  <ScalarProperty Name="ReportDate" ColumnName="ReportDate" />
                  <ScalarProperty Name="DistributionDate" ColumnName="DistributionDate" />
                  <ScalarProperty Name="ReportTypeId" ColumnName="ReportTypeId" />
                  <ScalarProperty Name="IsLocked" ColumnName="IsLocked" />
                  <ScalarProperty Name="EffectiveStartDate" ColumnName="EffectiveStartDate" />
                  <ScalarProperty Name="EffectiveEndDate" ColumnName="EffectiveEndDate" />
                  <ScalarProperty Name="Investor_ID" ColumnName="Investor ID" />
                  <ScalarProperty Name="Investor_Name" ColumnName="Investor Name" />
                </EntityTypeMapping>
              </ResultMapping>
              <ResultMapping>
                <EntityTypeMapping TypeName="IRISModel.ViewedReport">
                  <ScalarProperty Name="RecordID" ColumnName="RecordID" />
                  <ScalarProperty Name="ReportId" ColumnName="ReportId" />
                  <ScalarProperty Name="ReportDesc" ColumnName="ReportDesc" />
                  <ScalarProperty Name="ReportLink" ColumnName="ReportLink" />
                  <ScalarProperty Name="ReportDate" ColumnName="ReportDate" />
                  <ScalarProperty Name="DistributionDate" ColumnName="DistributionDate" />
                  <ScalarProperty Name="Mr_Ms" ColumnName="Mr/Ms" />
                  <ScalarProperty Name="Last_Name" ColumnName="Last Name" />
                  <ScalarProperty Name="First_MI" ColumnName="[First/MI]" />
                  <ScalarProperty Name="Company" ColumnName="Company" />
                  <ScalarProperty Name="LoginTime" ColumnName="LoginTime" />
                  <ScalarProperty Name="Contact_ID" ColumnName="Contact ID" />
                  <ScalarProperty Name="LastViewed" ColumnName="LastViewed" />
                  <ScalarProperty Name="Investor_Name" ColumnName="Investor Name" />
                </EntityTypeMapping>
            </ResultMapping>
          </FunctionImportMapping>            
          </EntityContainerMapping>
      </Mapping>
    </edmx:Mappings>

0 个答案:

没有答案