指定演员表无效?

时间:2013-12-11 16:26:03

标签: c# sql sql-server

**已解决**

问题是我更改了我的SQL服务器表,但后来没有在我的C#中更改我的实体。感谢所有的想法!

* D Stanley感谢您让我查看我的错误。

public partial class xamlAuditorDashboard : Window
{
    cEvolve_SP sp = new cEvolve_SP(Properties.Settings.Default.AppConnectionString);
    List<cAuditTasksEntity> _tasks;
    cAuditUserEntity _loggedInUser;
    public xamlAuditorDashboard(cAuditUserEntity loggedInUser)
    {
        _loggedInUser = loggedInUser;
        InitializeComponent();
        _tasks = new List<cAuditTasksEntity>();
        Refresh();
    }

    private void Refresh()
    {

        var _AuditUserId = _loggedInUser;
        cAuditUserEntity user = _AuditUserId as cAuditUserEntity;

        int userid = user.AuditUserId;

        _tasks = sp.GetTasksByUser(userid).ToList();
        cmbList.ItemsSource = (from cAuditTasksEntity tasks in _tasks
                                    select tasks.TaskId).ToList();

    }
}

通过将登录用户传递给构造函数,然后将其设置为_loggedInUser = loggedInUser;

,我找到了Logged on用户

对于该用户,我在Refresh方法中找到了ID,并最终获取其ID并将其设置为userid

我运行我的SP(存储过程),它选择指定ID下的所有内容 _tasks = sp.GetTasksByUser(userid).ToList();

假设将该表中的所有列结果带回该ID,并将其放入组合框cmbList.ItemsSource = (from cAuditTasksEntity tasks in _tasks select tasks.TaskId).ToList();

但运行Store Procedure的行是说它是一个无效的演员吗?

编辑:

这是我的类中存储过程的代码:

        [Function(Name = "SP_AUDIT_TASKS_GET_TASKS_BY_USER", IsComposable = false)]
    public ISingleResult<cAuditTasksEntity> GetTasksByUser(
       [Parameter(Name = "pAuditUserId", DbType = "INT")] int AuditUserId)
    {
        IExecuteResult objResult = this.ExecuteMethodCall(this, (MethodInfo)(MethodInfo.GetCurrentMethod()), AuditUserId);

        ISingleResult<cAuditTasksEntity> objresults = (ISingleResult<cAuditTasksEntity>)objResult.ReturnValue;

        return objresults;
    }

这是SQL代码:

        SELECT *
    FROM Audit_Tasks    
        WHERE (AuditUserId = @pAuditUserId)

0 个答案:

没有答案