Simon Thompson
Simon Thompson

Reputation: 704

LINQ string compare in VB when using NHibernate

Come across an issue when doing a string compare as part of the where section of a linq expression against LINQ for NHibernate.

from x in NhibernateObject
where x.StringCol = "value"
select x

When it runs it retrns a runtime error about casting to an integer. I found a nice post about the issue and the solution at http://jason.pettys.name/archive/2009/09/28/nhibernate-with-linq-error-with-string-comparisons-in-vb.net.aspx

But my question is what is a "visitor" and what code would I write to achive the solution highlighted in the above post - missing the link here !!!

Upvotes: 1

Views: 487

Answers (2)

Paco
Paco

Reputation: 8381

The definition of the visitor pattern is: "Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates."

The namespace of the visitor(s) you want to change is NHibernate.Linq.Visitors. You will probably have more difficulties using VB instead of C# with NHibernate.Linq, because VB3 does not support everything c#3 does. Those problems will be solved if you use .Net 4.0 (or c# of course)

Upvotes: 0

M4N
M4N

Reputation: 96571

Visitor is a design pattern. You can find a description of it here http://www.dofactory.com/Patterns/PatternVisitor.aspx or here http://en.wikipedia.org/wiki/Visitor_pattern

If I correctly understand the article you linked to (haven't read it fully), then it is required to change NHibernate to work around this problem.

Upvotes: 1

Related Questions