0

I need to create a Linq query having Where and Select both dynamic.I am searching something like below code which will work in .net core.

var result = myQuery
.Where("Field1=\"SomeValue\" && Field2=\"SomeValue\"")
.Select("new (Field1, Field2, Field3)");

I tried above one by adding System.Linq.Dynamic for .net core but both Where and Select is not supporting dynamic string values.Is there any way to achieve this ?

2
  • 1
    What is the problem? In string concatennation? Commented May 4, 2022 at 18:38
  • 1
    Dynamic LINQ is definitely the right solution. Please add more details on what is not working. Commented May 4, 2022 at 19:12

1 Answer 1

2
  1. Make sure to use NuGet : System.Linq.Dynamic.Core.

  2. And make sure you include the correct namespace:

    using System.Linq.Dynamic.Core;
    
  3. And make sure your myQuery is an IQueryable<T>


With this it should be able to use your code like:

example

Sign up to request clarification or add additional context in comments.

1 Comment

I was using System.Linq.Dynamic instead of System.Linq.Dynamic.Core that was the issue, thanks for the help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.