Created
July 27, 2017 06:43
-
-
Save cincauhangus/3a976c1d937271b6392d398364b4dcde to your computer and use it in GitHub Desktop.
SQL to LINQ String Comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dim value = "F!NDM3" | |
| ' strColumn LIKE '%F!NDM3%' | |
| Dim results1 = (From row In table Where row.strColumn.Contains(value) Select row.id) | |
| ' strColumn LIKE 'F!NDM3%' | |
| Dim results2 = (From row In table Where row.strColumn.StartsWith(value) Select row.id) | |
| ' strColumn LIKE '%F!NDM3' | |
| Dim results3 = (From row In table Where row.strColumn.EndsWith(value) Select row.id) | |
| ' strColumn LIKE 'F!NDM3' | |
| Dim results4 = (From row In table Where System.Data.Linq.SqlClient.SqlMethods.Like(row.strColumn, value) Select row.id) | |
| ' strColumn = 'F!NDM3' | |
| Dim results5 = (From row In table Where String.equals(row.strColumn, value) Select row.id) | |
| ' strColumn = 'F!NDM3' | |
| Dim results6 = (From row In table Where row.strColumn.equals(value) Select row.id) | |
| ' strColumn = 'F!NDM3' (case insensitive) | |
| Dim results7 = (From row In table Where String.compare(row.strColumn, value, StringComparison.OrdinalIgnoreCase) = 0 Select row.id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment