我遇到了Linq查询的问题,我试图在SQL中将其用作IN
。在Linq中想一想Contains
。我会发布我的代码,也许有人可以帮助我?
var claimsearch =
(from x in dbContext.view_ImageVerification_Shortened
where x.intCurrentImageVerificationStatusID.Contains.(2,3,4,5).
select new
{
intImageVerificationID = x.intImageVerificationID,
intClaimID = x.intClaimID,
intCurrentCaseStatusLookUpID = x.intCurrentCaseStatusLookUpID,
vcharCurrentCaseStatusName = x.vcharCurrentCaseStatusName,
vcharEnergyEmployeeFullName = x.vcharEnergyEmployeeFullName,
vcharClaimDocsTabHTTPNOCTSLink = x.vcharClaimDocsTabHTTPNOCTSLink,
intDocumentID = x.intDocumentID,
vcharDocumentName = x.vcharDocumentName,
intDocumentTypeID = x.intDocumentTypeID,
vcharDocumentType = x.vcharDocumentType,
vcharDocumentFullFileName = x.vcharDocumentFullFileName,
vcharDocumentHttpFullFileName = x.vcharDocumentHttpFullFileName,
intContainerID = x.intContainerID,
vcharContainerDescription = x.vcharContainerDescription,
intContainerTypeID = x.intContainerTypeID,
intCurrentImageVerificationTrackingID = x.intCurrentImageVerificationTrackingID,
intCurrentImageVerificationStatusID = x.intCurrentImageVerificationStatusID,
vcharCurrentImageVerificationStatusDescription = x.vcharCurrentImageVerificationStatusDescription,
intCurrentImageVerificationTrackingUserID = x.intCurrentImageVerificationTrackingUserID,
dtmCurrentImageVerificationTrackingDate = x.dtmCurrentImageVerificationTrackingDate,
vcharCurrentImageVerificationTrackingNotes = x.vcharCurrentImageVerificationTrackingNotes,
vcharCurrentImageVerificationStatusDescriptionUserAndDate = x.vcharCurrentImageVerificationStatusDescriptionUserAndDate,
intPageCount = x.intPageCount,
intClaimType = x.intClaimType
}).ToList();
答案 0 :(得分:4)
你的病情应该是:
where new[] {(int?) 2,3,4,5}.Contains(x.intCurrentImageVerificationStatusID)
// cast to int? for nullable
如果阵列中存在intCurrentImageVerificationStatusID
,则返回true。
您可以将数字提取到数组中,然后在查询中使用它,例如:
nt?[] array = new int?[] {2, 3, 4, 5 };
然后在条件中执行:
where array.Contains(x.intCurrentImageVerificationStatusID)