Skip to content
Advertisement

choose a few id from db C#

I have a database and excel file

And I want to export strings to excel

How to export strings with 1 id I know

The code you can see below

But how I can choose several id’s?

This does not work

I know, that it is an error, but how can I choose some ID’s?

Thanks for answers.

Advertisement

Answer

The reason it didn’t work is because each where clause is working on a subset of data that the previous one put out.

Use a list for your LINQ query’s boolean logic.

By manipulating the boolean this way, you can essentially convert a list of ints into a list of objects.

For your second where clause, I see you’re needing a different attribute to restrict the list even further. This would work, since each where clause operates on the results of the first, but for the reader’s sake it should be a &&.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement