1

I've mapped some function that is being used as a wrapper for the one of the Oracle functions (I really need to call that Oracle function from my LINQ).

My mapping looks like (Storage Model):

<Function Name="RunTranslate" IsComposable="false" BuiltIn="false">
    <CommandText>
        SELECT Translate(@DataToTranslate using char_cs) AS ResultData FROM dual
    </CommandText>
    <Parameter Name="DataToTranslate" Type="char" Mode="In" />
</Function>

And:

<FunctionImport Name="OracleTranslate" ReturnType="Collection(String)">
    <Parameter Name="DataToTranslate" Mode="In" Type="String" />
</FunctionImport>

I try to use it from the code this way:

using (var context = new TestEntities())
{
    ....

    var result = from myData in context.OracleTranslate("test")
                 select myData;    // Error ORA-00936!
    ....
}

I tried to use Entity Framework Profiler (EFProf) to see the query that is actually being sent to the DB. Intercepted query is the next:

SELECT Translate('test' /*@DataToTranslate*/ using char_cs) AS ResultData FROM dual

(looks fine)

But my application stops with the next error: ORA-00936: missing expression

If I copy-paste the intercepted query into the VS2010's Server Explorer Query Window - it works! DB returns correct data to me!

So, where the problem can be? What is the difference between the code and the query window in my case? I thought they use the same provider, etc...

Thank you very much!

EDIT:

I've just used standard Inet-sniffer to check the real data that is being sent over the sockets and Internet when I run my query.

And it's not the same with the first one! It's exactly my source SQL query:

SELECT Translate(@DataToTranslate using char_cs) AS ResultData FROM dual

It seems, that parameter is not recognized, but why?

4

1 回答 1

1

我找到了解决方案,希望此信息对某人有所帮助:

DataToTranslate 参数应映射为冒号 (":DataToTranslate"),而不是 "@"。

另一个重要的经验(对我而言):Entity Framework Profiler (EFProf) 显示了它想要的东西,而不是真实的数据——使用像 Wireshark 这样的 TCP 嗅探器来查看数据要好得多。

于 2012-08-23T14:14:18.403 回答