2012-04-02 68 views
2

我将挖掘结构从2008服务器迁移到2012服务器。当我尝试我的CLR UDF在DMX查询2012年的服务器上(这是工作的罚款SQL Server 2008上),我收到此错误:Context.CurrentMiningModel在UDF中返回NULL

Exception has been thrown by the target of an invocation. Object reference not set to an instance of an object.

我最初的目标是让GetNodeDescription(...)方法运行。在调试的问题,我可以将问题隔离到这个UDF从而未能我的SQL服务器2012

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

我的猜测是,CurrentMiningModel为null,因为下面的代码工作正常

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

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

谢谢。

UPDATE: 在微软的接触,由于确认所期望的“元数据的重构”(无论这意味着...)这种行为。但是,website仍然有适当的更新。

回答

0

这不是最终的答案,但它是一个解决方法,以获得微软的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; 
}