0

How can you insert a WHERE IN clause using parameter in net core? They are a list of strings. I have tried everything but doesn't seem to work. Tried String.Join("','",myList) and it looked ok but it doesn't return from the database. Tried the same query on sql server and returns the data as expected.

2
  • That's not really possible as the commas in the list are not treated as delimiters but just a value. However, using dynamic SQL you can work around it: stackoverflow.com/questions/5401641/…. Be super careful and properly escape the strings; otherwise you create an SQL injection vulnerability. Commented May 29, 2018 at 14:58
  • Thank you for your guidance, I have come up with a solution which is not the best but works perfectly. I return the full list from the database then using linq I query the object using .WHERE(x=>object.Contains(x.item)). This filters out the needed data and returns back what i need. Commented Jun 3, 2018 at 19:40

0

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.