I get a list of objects to update, and I have their identifiers. I want to get the source data from a database, so I:
String[] ids = updatedEvents.Select(ue => ue.id).ToArray(); var originalEventsToUpdate = Db.tbl_ffk_event .Where(e => ids.Contains(e.id)) .ToArray();
But what I get using the log is the generated SQL:
SELECT [t0].[id], [t0].[fs_mapping_id], [t0].[fs_id_value], [t0].[desc] FROM [dbo].[tbl_ffk_event] AS [t0] WHERE 0 = 1
And this SQL means "get the whole table".
How can I create an "IN" like this:
SELECT [t0].[id], [t0].[fs_mapping_id], [t0].[fs_id_value], [t0].[desc] FROM [dbo].[tbl_ffk_event] AS [t0] WHERE [t0].[id] IN ('aaa','bbb','ccc','ddd','eee',)
Thanks in advance.
EDIT:
I feel stupid, I have not seen WHERE 0 = 1 . This is because at that moment where there is nothing in the ids collection. I have now checked for item availability, and SQL is generated correctly. Unfortunately.
source share