使用ObjectQuery调用ms-sql存储过程

时间:2015-12-14 14:27:30

标签: c# entity-framework

如何使用ObjectQuery调用存储过程? 这是我的代码:

using (var dc = new DAL.ImpulseScreens.ImpulseScreensEntities())
{
    string query = "EXECUTE dbo.GetACLentry @AppName, @WindowsUserID, @EntryType, @PassPhrase";

    var data = new System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord>(query, dc);
    data.Parameters.Add(new System.Data.Objects.ObjectParameter("AppName", Settings.ParentAppName));
    data.Parameters.Add(new System.Data.Objects.ObjectParameter("WindowsUserID", Settings.WindowsUserName));
    data.Parameters.Add(new System.Data.Objects.ObjectParameter("EntryType", (int)type));
    data.Parameters.Add(new System.Data.Objects.ObjectParameter("PassPhrase", PASS_PHRASE));

    foreach (var x in data)
    {
         var i = x.GetOrdinal("ImpulseUserID");
         var v = x.GetValue(i);
    }
}

但它有一个例外:

  

“查询语法无效。靠近标识符'dbo',第1行,列   9。“

0 个答案:

没有答案