Im new to linQ and I’ve got a problem
Question: if i have a string Example “MySTring”and I need the characters at positions 5 and 6 counting from the right of the string, ie: “ST”
here’s my Query
Dim result = From everyval in AllVals
where everyval.Substring(5,2)=’ST’
select everyval.Name
Now this wont return the correct values from the database because the default Consideration of positions in the Substring Function is from LEft to Right.
One Solution is maybe to reverse the String and then apply the Substring Function to it.
But how should i be doing this?
can someone tell me..???
This is a rather strange requirement, usually an
IndexOf/Containsis good enough for this. However, you could try (conceptually) truncating the value and testing the end usingEndsWith.Something like this perhaps (untested and probably doesn’t work):
MSDN nicely lists the string functions that can be safely translated to SQL from LINQ: http://msdn.microsoft.com/en-us/vbasic/bb688085