C# System.Reflection.targetingException:&x27;调用的目标已引发异常

C# System.Reflection.targetingException:&x27;调用的目标已引发异常,c#,sql,entity-framework,C#,Sql,Entity Framework,我正在使用实体框架和存储过程以及crystal report 我想获取存储过程并在crystal report中查看它 但是我得到了这个错误 System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.' inner exception NullReferenceException: Object reference not set to an in

我正在使用实体框架和存储过程以及crystal report

我想获取存储过程并在crystal report中查看它

但是我得到了这个错误

System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

inner exception
NullReferenceException: Object reference not set to an instance of an object.

This exception was originally thrown at this call stack:
    CrystalDecisions.CrystalReports.Engine.Table.Fields.get()
这就是存储过程

USE [PayRoll]
GO
/****** Object:  StoredProcedure [dbo].[SR1]    Script Date: 12/09/2020 15:41:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER Procedure [dbo].[SR1]

As
BEGIN

SELECT         
                         EmployeeCode,EmployeeName,JopName,Date_Hiring,Nat_Salary
FROM            
                         Employee_List_Code_Name_Jop_DateHiring 
END 

这是调用存储过程的代码 此处显示rpt.SetDataSource(bs)时出错


如何修复此错误???

我在sql查询中遇到错误

替换

SqlQuery

SqlQuery

像这样


if(Report_Number == "2")
            {
                var Employee_Data = db.Database.SqlQuery<SR1_Result>("SR1").ToList();
                bs.DataSource = Employee_Data;
            }


如果(报告编号=“2”)
{
var Employee_Data=db.Database.SqlQuery(“SR1”).ToList();
bs.DataSource=员工数据;
}
namespace PayRoll.database
{
    using System;
    
    public partial class SR1_Result
    {
        public int EmployeeCode { get; set; }
        public string EmployeeName { get; set; }
        public string JopName { get; set; }
        public System.DateTime Date_Hiring { get; set; }
        public double Nat_Salary { get; set; }
    }
}

if(Report_Number == "2")
            {
                var Employee_Data = db.Database.SqlQuery<SR1_Result>("SR1").ToList();
                bs.DataSource = Employee_Data;
            }