Jasmine Jasmine - 1 year ago 66
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?

Answer Source

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

    .Where(article => input.Any(x => SQLFunction.Difference(article.Text, x) == 3))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download