This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Guys, I'm trying to search on a feild name using wildcards for example:
from s in uow.stuff where somename like 'in*du*er*oo*' Does LightSpeed support this?
You can do .StartsWith('in') && .Contains('du') && .Contains('er') && .Contains('oo'), but this doesn't take into account the order of the search terms in the .Contains statements
Thanks Again, Josh |
|
|
You can do it in the core API by using the .Like operator. In LINQ, it's a bit trickier because there's no CLR String method that represents pattern matching of this kind -- but there *is* a Visual Basic keyword that does it, and we do support that. If you're using VB, you can use this directly, e.g. Dim query = From c In UnitOfWork.Contributions _ However, if you're using C#, which I think you are, the only way to get at the VB Like operator is to reference Microsoft.VisualBasic.dll (part of the .NET Framework), and call the Microsoft.VisualBasic.CompilerServices.LikeOperator.LikeString method: var query = from c in UnitOfWork.Contributions Note that the wildcard syntax for the Like operator is not the same as the SQL wildcard syntax. Consult the VB documentation for info. Also note that support for some Like patterns may be database-dependent. |
|
|
the LikeOperator doesn't work when the item being compared with is not directly on the object. For example: var query = from c in UnitOfWork.Contributions
Is there a way to make it work? Thanks |
|
|
I don't think there's a way around this in the current builds, but I've committed a fix and it will be in nightly builds dated 8 Sept 2010 and above (available from about 1500 GMT). As always, let us know if you still see problems. |
|
|
Can i do this using LAMBDA?
C# Code query.Where(m => m.Addresses.Address1.ToLower().Contains("111%blah")
SQL Gen by LS AND LOWER(t1.Address1) LIKE '%110%\\blah%' ESCAPE '\')
I need it to be AND LOWER(t1.Address1) LIKE '%110%blah%' ESCAPE '\')
Help?!?!?!
Josh |
|
|
|
|