views:

495

answers:

0

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" ?