| LIKE Operator | Description |
|---|---|
| WHERE LastName LIKE 'a%' | Finds values that start with "a" |
| WHERE LastName LIKE '%a' | Finds values that end with "a" |
| WHERE LastName LIKE '%ab%' | Finds values that have "ab" in any position |
| WHERE LastName LIKE '_a%' | Finds values that have "a" in the second position |
| WHERE LastName LIKE 'a_%' | Finds values that start with "a" and are at least 2 characters in length |
| WHERE LastName LIKE 'a__%' | Finds values that start with "a" and are at least 3 characters in length |
| WHERE LastName LIKE 'a%e' | Finds values that start with "a" and ends with "e" |
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
| var startsWith1 = dbContext.Customers.Where(x => x.LastName.StartsWith("pe")).Select(x => x.LastName).ToList(); | |
| Logger.LogInformation(string.Join("\t", startsWith1)); | |
| // Translated SQL: | |
| // SELECT "c"."LastName" | |
| // FROM "Customers" AS "c" | |
| // WHERE "c"."LastName" IS NOT NULL AND ("c"."LastName" LIKE 'pe%') | |
| // Output: Perko petersen Perez | |
| var startsWith2 = dbContext.Customers.Where(x => x.LastName.ToLower().StartsWith("pe")).Select(x => x.LastName).ToList(); |
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
| var result = dbContext.Customers | |
| .Where(x=> x.LastName.StartsWith("pe", StringComparison.CurrentCultureIgnoreCase)) | |
| .ToList(); | |
| // [WARN] [Microsoft.EntityFrameworkCore.Query] | |
| // The LINQ expression 'where [x].LastName.StartsWith(__id_0, CurrentCultureIgnoreCase)' | |
| // could not be translated and will be evaluated locally. |
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
| public static int CalculateAge(DateTime birthday, DateTime now) | |
| { | |
| if (birthday == DateTime.MinValue) | |
| { | |
| throw new ArgumentException("Date of birth is invalid.", nameof(birthday)); | |
| } | |
| if (birthday >= now) return 0; | |
| var age = now.Year - birthday.Year; |
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
| public int CalculateAge(DateTime birthday) | |
| { | |
| var today = DateTime.Today; | |
| var age = today.Year - birthday.Year; | |
| if (birthday.DayOfYear > today.DayOfYear) | |
| { | |
| age--; | |
| } | |
| return age; | |
| } |
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
| # build an image "login-e2e-cypress" from the current directory | |
| docker build -t login-e2e-cypress . | |
| # run the e2e tests in a container | |
| docker run -it login-e2e-cypress -- -e username=$TESTUSERNAME,password=$TESTPASSWORD |
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
| FROM cypress/base:12.16.1 | |
| WORKDIR /e2e | |
| # copy the test folder and related json files | |
| COPY ./cypress ./cypress | |
| COPY ./cypress.json . | |
| COPY ./package.json . | |
| COPY ./package-lock.json . |
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
| docker run -it -v /$PWD://e2e -w //e2e cypress/included:4.5.0 \ | |
| -e username=$TESTUSERNAME,password=$TESTPASSWORD |
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
| export CYPRESS_username="tomsmith" | |
| export CYPRESS_password="SuperSecretPassword!" |
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
| export TESTUSERNAME="tomsmith"; | |
| export TESTPASSWORD="SuperSecretPassword!"; |