Entity Framework: combining exact and wildcard searching conditional on search term
问题 I'm creating a query to search the db using EF. TdsDb being the EF context. string searchValue = "Widget"; TdsDb tdsDb = new TdsDb(); IQueryable<Counterparty> counterparties; I can do exact match: counterparties = tdsDb.Counterparties.Where(x => x.CounterpartyName == searchValue); or wildcard match: counterparties = tdsDb.Counterparties.Where(x => x.CounterpartyName.Contains(searchValue)); But I want to be able to do both i.e. (psudo code) counterparties = tdsDb.Counterparties.Where(x => if