I get a list of entities to update and I have their ids. I want to get the original ones from the database, so I do:
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 this 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
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 4.0.30319.1
And that SQL means "get the whole table".
How can I generate a "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 didn't see the WHERE 0 = 1
. It's because at that point, there where nothing in the ids
collection. I have checked out now ensuring there are items, and the SQL is generated correctly. Sorry.