Jasmine Jasmine - 5 months ago 23
C# Question

Search by multiple strings using SQLFunction.Difference with EF

This works great when the input is a single string

In this example "Lorem ipsum"

dbContext.NewsArticles.Where(article => SQLFunction.Difference(article.Text, "Lorem ipsum") == 3).ToArray()

How can I search by multiple strings? In other words, the input is a string[] or List

var input = new List<string>{
"Lorem ipsum dolor",
"elementum lacinia",
"cursus nulla molestie",

Is this even possible?


You should be able to just use that list with Any.

    .Where(article => input.Any(x => SQLFunction.Difference(article.Text, x) == 3))