Last post Feb 06, 2015 01:59 AM by Kevin Shen - MSFT
Feb 05, 2015 07:30 AM|mou_inn|LINK
i search google and found people use Contains for Line and In operator. but like and In operator is different and used for different purpose then how contains can do the same job for both IN & Like operator ?
var portCode = Database.DischargePorts
.Single(p => p.PortName.Contains("BALTIMORE"))
suppose my like could be '%USA' or could be like '%USA%' or 'USA%' how this can be solved with Contains operator? looking for suggestion. thanks
from this url i came to know
Contains() is translated LIKE '%term%'
StartsWith() = LIKE 'term%'
EndsWith() = LIKE '%term'
Feb 05, 2015 07:59 AM|Lokesh B R|LINK
Contains will do all the functionality as LIKE.
Contains will find the sub-string whether it is at starting/middle/end.
Feb 06, 2015 01:59 AM|Kevin Shen - MSFT|LINK
the "Contains" method will search the result which contain the keyword ,no matter if its position of your words.
If you want to get result like "%USA" Or 'USA%',you still need to use "StartsWith"and "EndsWith".