How to search int[] Array in list or Entity?
How to search int[] QTaskId in Entity. i try to make below but i can not
void (Run(int[] QTaskId)
{
var Que = calculateCtx.QTaskRelations.Where(q => q.QTaskId.Contains(QTaskId)).Select(q 开发者_StackOverflow中文版=> q);
}
I think you've just got the contains wrong. Instead of this:
Where(q => q.QTaskId.Contains(QTaskId))
try this:
Where(q => QTaskId.Contains(q.QTaskId))
I would also suggest changing your parameter name to something more easily understandable, such as "validTaskIds" (note the plural, as well as the camelCased name). Then:
Where(q => validTaskIds.Contains(q.QTaskId))
You have to look the other way around: you have to search the "QTaskId" array for "q.QTaskId":
void (Run(int[] QTaskId)
{
var Que = calculateCtx.QTaskRelations.Where(q => QTaskId.Contains(q.QTaskId)).Select(q => q);
}
精彩评论