SubSonic 3 / ActiveRecord:非主键字段上的 Find() 失败(仅限 VB.NET)
当我在非主键字段上调用 Find() 时,出现 SqlException。 我只有在 VB 中进行此调用时才会遇到这种情况。
详细信息:
- SubSonic 3.0.0.3 和 ActiveRecord
- Visual Studio 2008 解决方案
- C# 类库项目中的 SubSonic 和 T4 模板
- 我的 VB 应用程序位于引用 SubSonic 项目的单独项目中
在我的 VB 应用程序中,我尝试对 SubSonic 生成的类之一调用 Find(),如下所示
dim foo = Orders.Find(Function(myOrder as Order) myOrder.CustomerID = 1)
:在 ActiveRecord.cs 中,在来自(生成的)Order 类的此方法中失败:
public static IList<Order> Find(Expression<Func<Order, bool>> expression) {
var repo = GetRepo();
return repo.Find(expression).ToList(); '<---- exception here
}
存在以下异常
SqlException was unhandled by user code Incorrect syntax near 'LESS_THAN_SIGN'
(将 LESS_THAN_SIGN
替换为小于号;无法弄清楚 stackoverflow 中的转义)
当我使用引用主键的函数调用 Find 时没有问题,例如:
dim foo = Orders.Find(Function(myOrder as Order) myOrder.OrderID = 1)
当我在 C# 中执行此操作时也没有问题。
我究竟做错了什么? 这与 “VB.net 无法按字符串查找” 有关吗?
I'm getting an SqlException when I call Find() on a non-primary key field. I only experience this when I make this call in VB.
Details:
- SubSonic 3.0.0.3 and ActiveRecord
- Visual Studio 2008 solution
- SubSonic and T4 templates in a C# class library project
- My VB application in a separate project referencing the SubSonic project
In my VB application, I am trying to call Find() on one of the SubSonic generated classes, like so:
dim foo = Orders.Find(Function(myOrder as Order) myOrder.CustomerID = 1)
This is failing in ActiveRecord.cs, in this method from the (generated) Order class at:
public static IList<Order> Find(Expression<Func<Order, bool>> expression) {
var repo = GetRepo();
return repo.Find(expression).ToList(); '<---- exception here
}
with the following exception
SqlException was unhandled by user code Incorrect syntax near 'LESS_THAN_SIGN'
(Replace the LESS_THAN_SIGN
with a less than sign; can't figure out the escaping in stackoverflow)
I don't have a problem when I call Find with a function that references the primary key, such as:
dim foo = Orders.Find(Function(myOrder as Order) myOrder.OrderID = 1)
I also don't have a problem when I do this in C#.
What am I doing wrong? Is this related to "VB.net can’t find by string" ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论