2

我将 Mining Structures 从 2008 服务器迁移到 2012 服务器。当我在 2012 服务器上的 DMX 查询中尝试我的 CLR UDF(在 SQL Server 2008 上运行良好)时,我收到此错误:

调用的目标已引发异常。你调用的对象是空的。

我最初的目标是让GetNodeDescription(...)方法运行。在调试问题时,我可以将问题隔离到这个在我的 SQL Server 2012 上失败的 UDF

[SafeToPrepare(true)]
public static string test()
{
  return Context.CurrentMiningModel.Name;
}

我的猜测是CurrentMiningModelnull 因为以下代码可以正常工作

[SafeToPrepare(true)]
public static string testUser()
{
 return Context.CurrentConnection.User.Name;
}

关于如何解决这个问题的任何想法?有人可以重现这个吗?

谢谢。

更新:由于“元数据重构”(无论这意味着什么......),Microsoft 的一位联系人确认了这种行为。但是,该网站仍有待适当更新。

4

1 回答 1

0

这不是最终答案,但它是让 Microsoft 的GetNodeDescription工作的一种解决方法(通过明确提供挖掘模型):

[SafeToPrepare(true)]  
public static string GetNodeDescription(string MiningModel, string nodeUniqueName)  
{  
  if (Context.ExecuteForPrepare)  
  {
    return string.Empty;  
  }  
  return Context.MiningModels[MiningModel].GetNodeFromUniqueName(nodeUniqueName).Descript‌​ion;  
}
于 2012-04-24T10:11:41.773 回答