VB.net 无法按字符串查找 [英] VB.net can't find by string
问题描述
使用 VB.net,下面的代码片段给出了下面的错误.
Using VB.net, the following snippet gives the error below.
Dim _account = Account.Find(Function(x As Account) x.AccountName = txtFilterAccountName.Text)
或者类似的,如果我这样做
or similarly if I do
.SingleOrDefault (Function(x As Account) x.AccountName = txtFilterAccountName.Text)
都会给出错误不支持‘CompareString’方法".如果我进行相同的调用以搜索整数(ID 字段),则它工作正常.
will both give the error "The method 'CompareString' is not supported". If I make the same call searching for an integer (ID field) it works fine.
.SingleOrDefault (Function(x As Account) x.Id = 12)
所以整数匹配很好,但字符串不起作用这是VB.net模板的问题吗?
So integer matching is fine but strings don't work Is this a problem with the VB.net templates?
推荐答案
问题在于 SubSonic3 的 SQL 生成器和从 VB.NET 生成的表达式树.
The problem is with SubSonic3's SQL generator and the expression tree generated from VB.NET.
VB.NET 生成一个不同的表达式树,正如 JaredPar 所指出的,SubSonic3 没有考虑到它 - 参见 问题 66.
VB.NET generates a different expression tree as noted by JaredPar and SubSonic3 doesn't account for it - see Issue 66.
我已将修复实施为 描述,但尚未合并到 SubSonic3 的主分支.
I have implemented the fix as described but it has yet to merge into the main branch of SubSonic3.
这篇关于VB.net 无法按字符串查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!