简体   繁体   English

无法通过 EF 将参数传递给 Oracle 数据库

[英]can't pass parameters via EF to Oracle Database

as the the title implies, I got an "ORA-00932: inconsistent datatypes: expected - got NCLOB" when passing a string value with linq through the Entity Framework.正如标题所暗示的那样,当通过实体框架使用 linq 传递字符串值时,我得到了"ORA-00932: inconsistent datatypes: expected - got NCLOB"

I'm using VS 2010, ODAC 2011 with EF support.我正在使用带有 EF 支持的 VS 2010、ODAC 2011。

I tried passing the value itself (no variable but directly using the "") and it just worked fine, I've tested my variable and yeah it is fine and it provides the right value.我尝试传递值本身(没有变量,但直接使用“”),它工作得很好,我已经测试了我的变量,是的,它很好,它提供了正确的值。 I guess it is a bug somewhere and the string value reach Oracle wrongly, anyone faced this?我猜这是某个地方的错误,字符串值错误地达到了 Oracle,有人遇到过这个吗? Any work arround?周围有工作吗?

Thanks in advance提前致谢

public ObservableCollection<String> getCarModels(string carName)
{
    carContext = new Entities();
    carModelNamesList = new ObservableCollection<string>();
    var result = from d in carContext.CARs
                 where d.NAME == carName
                 select d;
    foreach (CAR d in result)
    {
        string f = d.MODEL;
        carModelNamesList.Add(f);
    }
    return carModelNamesList;           
}

guys, sorry it is my bad, the variable is null when the event occured, in my way of testing was using another event, so the variable is having the right value when the my test event occured and having null when the acctual event occured, I hope this may help someone.伙计们,对不起,这是我的错,事件发生时变量是 null,在我的测试方式中使用的是另一个事件,所以当我的测试事件发生时变量具有正确的值,并且当实际事件发生时具有 null,我希望这可以帮助某人。

I got the same error when I tried to check a varchar2 against a String.Empty value in my Where clause.当我尝试根据 Where 子句中的 String.Empty 值检查 varchar2 时,我遇到了同样的错误。 This caused me a lot of lost time trying to figure out what's going on.这让我浪费了很多时间试图弄清楚发生了什么。 I guess you got to be careful on what you're conditions looks like because Oracle can be very picky!我想你必须小心你的条件,因为 Oracle 可能非常挑剔!

I also wanted to add, our team just got this same error and it was resolved by refreshing the Entity Model from the database.我还想补充一点,我们的团队也遇到了同样的错误,通过从数据库中刷新实体 Model 解决了这个错误。 I had modified the designer to make a column nullable but I guess that wasn't the cleanest way to do it since it "confused" the EF engine.我已经修改了设计器以使列可以为空,但我想这不是最干净的方法,因为它“混淆”了 EF 引擎。 After refreshing from the database it coded the way it wanted to see a nullable column in the designer code and we were good after that.从数据库刷新后,它编写了希望在设计器代码中看到可为空列的方式,之后我们就很好了。

Of course, we have no idea what was really going on behind the EF curtain and why this would trip it up.当然,我们不知道 EF 幕后到底发生了什么,以及为什么会绊倒它。 Seems like a bug.似乎是一个错误。 Why shouldn't we be able to adjust a column's attributes in the designer directly?为什么我们不能直接在设计器中调整列的属性?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM