实体框架、devArt 和 Oracle VarChar 参数
您好:我正在使用 devArt 的 Oracle Connect 来处理 Entity Framework 4.1 POCO 和 Oracle。
我在 Oracle 列类型为 Char(固定长度)的某些查询中遇到问题。生成的 SQL 查询中使用的参数格式为 VarChar 而不是 Char,这导致我的查询返回零行。有没有办法强制 EntityFramework/DevArt 填充参数?
这是问题的示例(查询用户名)。此代码应该返回行,但事实并非如此。
string aUserName = "Test";
var query = from u in users
where u.UserName == aUserName
select u;
如果我将第一行代码更改为:
string aUserName = "Test".PadRight(20);
那么它就可以工作(Oracle 列是 Char(20))。我不想进行填充(对于 SQL Server,我不需要这样做)。我可以进行一些配置更改吗?连接字符串开关?我的 POCO 上的属性?
Hello: I am using devArt's Oracle Connect to work with Entity Framework 4.1 POCO's and Oracle.
I have a problem with certain queries where the Oracle column type is Char (fixed-length). The parameter that is used in the generated SQL query is formatted as a VarChar instead of a Char, and it is causing my queries to return zero rows. Is there some way to force EntityFramework/DevArt to pad the parameter?
Here's an example of the problem (querying for a username). This code should return rows, but it does not.
string aUserName = "Test";
var query = from u in users
where u.UserName == aUserName
select u;
If I change the first line of code to:
string aUserName = "Test".PadRight(20);
Then it works (the Oracle column is Char(20)). I would like to not have to do the padding (I don't have to with SQL Server). Is there some configuration change that I can make? A connection string switch? An Attribute on my POCO?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有两个选择:
1. 执行您所做的操作并向右填充用户名字符串变量。
2. 删除空字符 - 向右修剪用户名字段。
其他选项:(
这将返回用户名而不是整个用户对象)
希望这有帮助。
You have two options:
1. Do what you did and pad right the user name string variable.
2. remove empty chars - trim right the username field.
Other option:
(this will return you the user names and not the whole user objects)
Hope this helps.
我们已在我们的论坛此处回复您。
如果您在使用所提供的解决方案时遇到任何问题,请通知我们。
We have replied to you here at our forum.
Please inform us if you encounter any problems with the provided solution.