Tuesday, February 27, 2018

Is it possible to mix writing an EF Core query with LINQ and strings?

Sorry for the confusing title. But I was hoping to be able to write most of the query in LINQ, but then write the WHERE clause as a string, like you would a dynamic query. So something like:

var query = from part in _context.CurrentInventory

query.Where = "part.PartNumber LIKE '%a%' OR part.PartNumber LIKE '%b%'

The reason is because the WHERE can get quite large and using EF.Functions.Like really slows down the query.

I could build the whole thing dynamically and just execute the string, but I was hoping to avoid that unless necessary.

Is it possible to mix writing an EF Core query with LINQ and strings? Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team