1

当我的代码尝试执行.dbml文件中存在的存储过程时,我得到以下堆栈跟踪。

异常发现传输:System.Data.SqlClient.SqlException:
无效的对象名称't​​_wfe_user_role'。
在 System.Data.SqlClient.SqlConnection.OnError(SqlException异常,Boolean breakConnection) 在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
异常,Boolean breakConnection)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
在 System .Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
在 System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
在 System.Data.SqlClient.SqlDataReader.get_MetaData()
在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
在 System.Data.SqlClient。
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand 的SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String 方法, DbAsyncResult 结果) System.Data.SqlClient.SqlCommand .ExecuteReader(CommandBehavior 行为,String 方法)
在 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior 行为)
在 System.Data.Common.DbCommand.ExecuteReader()
在 System.Data.Linq.SqlClient.SqlProvider.Execute(表达式查询,QueryInfo queryInfo,IObjectReaderFactory 工厂,对象 [ ] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
在 System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(表达式查询)
在 System.Data.Linq.DataContext.ExecuteMethodCall(对象实例,MethodInfo 方法信息,对象 [] 参数)
在C:\Documents and Settings\Administrator\My Documents\SPSM-Bidragshantering_Origo\SPSM\Main\CommonData\LinqDataClasses\DataClasses\Workflows.designer.cs 中的 LinqDataClasses.DataClasses.WorkflowsDataContext.sp_wfe_transfer_task_force(Nullable 1 p_d2_user_ref, Nullable1 p_d2_diary_ref, Nullable 1 p_transfer_ref): C:\Documents and Settings\Administrator\My Documents\SPSM-Bidragshantering_Origo\SPSM\Main\SIS\Applications\SIS-PreliminaryDecision\ContinueWorkflows.cs 中 SPSM.ContinueWorkflows.ContinueWFs(Int32[] case, String type) 的1 p_state_ref, Nullable第 347 行:
第 67 行

我唯一的怀疑是多元化本身是如何绊倒的。数据库中没有命名表t_wfe_user_role。它被称为,但随后 Linq在文件的 GUI 中将其t_wfe_user_roles重命名。这个表是一个有两个外键的连接表。t_wfe_user_role.dbml

有任何想法吗!?

这是我调用存储过程的代码片段。通话结束(sp_wfe_transfer_task_force):

public class ContinueWorkflows
{
    public AppVariables _APPVARS = new Utility.AppVariables();
    public void ContinueWFs(int[] cases, string type)
    {
        foreach (int Case in cases)
        {
            if (Case != 0)
            {
                _APPVARS = (Utility.AppVariables)System.Web.HttpContext.Current.Session["CommonAppVariables"];
                LinqDataClasses.DataClasses.WorkflowsDataContext wfdc = new LinqDataClasses.DataClasses.WorkflowsDataContext(_APPVARS.SQLConnectionString);
                LinqDataClasses.DataClasses.t_wfe_workflow wf = wfdc.t_wfe_workflows.Where(p => p.c_d2_case_ref == Case && p.c_cancelled != true).FirstOrDefault();
                if (wf != null)
                {
                    LinqDataClasses.DataClasses.t_wfe_state state = wfdc.t_wfe_states.Where(p => p.c_workflow_ref == wf.c_rowid && p.c_cancelled != true).FirstOrDefault();
                    if (state != null)
                    {
                        LinqDataClasses.DataClasses.t_wfe_transfer transfer;
                        if (type == "Beslut")
                        {
                            transfer = wfdc.t_wfe_transfers.Where(p => p.c_from_step_ref == state.c_step_ref && p.c_name == "Till beslut" && p.c_cancelled != true).FirstOrDefault();
                            if (transfer == null)
                            {
                                transfer = wfdc.t_wfe_transfers.Where(p => p.c_from_step_ref == state.c_step_ref && p.c_name == "Övergång direkt till beslut" && p.c_cancelled != true).FirstOrDefault();
                            }
                            if (transfer == null)
                            {
                                transfer = wfdc.t_wfe_transfers.Where(p => p.c_from_step_ref == state.c_step_ref && p.c_name == "Övergång till beslut" && p.c_cancelled != true).FirstOrDefault();
                            }
                        }else if (type == "BVS")
                        {
                            transfer = wfdc.t_wfe_transfers.Where(p => p.c_from_step_ref == state.c_step_ref && p.c_name == "Stopp" && p.c_cancelled != true).FirstOrDefault();
                        }
                        else if (type == "TUFF")
                        {
                            transfer = wfdc.t_wfe_transfers.Where(p => p.c_from_step_ref == state.c_step_ref && p.c_name == "Preliminärt besked" && p.c_cancelled != true).FirstOrDefault();
                        }
                        else // SIS Prel Besked
                        {
                            transfer = wfdc.t_wfe_transfers.Where(p => p.c_from_step_ref == state.c_step_ref && p.c_name == "Övergång till preliminärt besked" && p.c_cancelled != true).FirstOrDefault();
                        }
                        if (transfer != null)
                        {
                            //Do transfer
                            int transref = transfer.c_rowid;
                            wfdc.sp_wfe_transfer_task_force(1, _APPVARS.DiaryRef, state.c_rowid, transref);
                        }
                    }
                }
            }
        }
    }
}
4

1 回答 1

0

if there is no issue with re generating data model then you can turn off pluralization and the generate class . in visual studio On the Tools menu, click Options.

In the Options dialog box, expand Database Tools.

(Note:Select Show all settings if the Database Tools node is not visible.)

Click O/R Designer.

Set Pluralization of names to Enabled = False to set the O/R Designer so that it does not change class names.

Set Pluralization of names to Enabled = True to apply pluralization rules to the class names of objects added to the O/R Designer.

otherwise You can change the generated name by right-clicking the table in the dbml designer window and selecting properties. There is a field called 'name' with which you should be able to define a custom name.

于 2012-08-01T14:55:17.607 回答