实体框架、devArt 和 Oracle VarChar 参数

发布于 2024-11-04 11:23:19 字数 588 浏览 8 评论 0原文

您好:我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

z祗昰~ 2024-11-11 11:23:19

您有两个选择:
1. 执行您所做的操作并向右填充用户名字符串变量。
2. 删除空字符 - 向右修剪用户名字段。

其他选项:(

string aUserName = "Test";
var query = users.select(x => string.Join(string.Empty, x.UserName).TrimEnd()).
                  where(x => x==aUserName)

这将返回用户名而不是整个用户对象)

希望这有帮助。

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:

string aUserName = "Test";
var query = users.select(x => string.Join(string.Empty, x.UserName).TrimEnd()).
                  where(x => x==aUserName)

(this will return you the user names and not the whole user objects)

Hope this helps.

云之铃。 2024-11-11 11:23:19

我们已在我们的论坛此处回复您。
如果您在使用所提供的解决方案时遇到任何问题,请通知我们。

We have replied to you here at our forum.
Please inform us if you encounter any problems with the provided solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文