I suppose that would depend on the type of myCollection is which dictates how Contains() is implemented. If a sorted binary tree for example, it could search smarter. Also it may take the element's hash into account. Any() on the other hand will enumerate through the collection until the first element that satisfies the condition is found. There are no optimizations for if the object had a smarter search method.
var result = context.Projects.Where(x => lstBizIds.Contains(x.businessId)).Select(x => x.projectId).ToList();
这将给出查询
选择 ID
来自贫民区
内连接(VALUES (1) ,(2) ,(3) ,(4) ,(5)) AS Data (Item) ON Projects. UserId = Data. Item
内连接(VALUES (1) ,(2) ,(3) ,(4) ,(5)) AS Data (Item) ON Projects. UserId = Data. Item 内连接(VALUES (1) ,(2) ,(3) ,(4) ,(5)) AS Data (Item) ON Projects. UserId = Data