我有 5-6 个文本框和下拉列表,基于我想要获取结果的值,使用 OR 条件,此查询工作正常,但是当我对多个条件使用 AND 时,由于显而易见的原因,它不会给我任何结果。现在我的问题是如何更改此查询以使其适用于 AND 和 OR 条件。
询问
Public Sub SerachCriteria()
Debugger.Break()
Dim s = New Ex1DataContext(SPContext.Current.Web.Url)
Dim vendors = s.PurchaseOrderWrite
Dim query = From vendor In vendors.ToList() _
Where (Not ddsearchorderVendor.SelectedItem.Text = "--Select--" AndAlso vendor.Supplier.Title = ddsearchorderVendor.SelectedItem.Text) _
Or (Not ddsearchorderStatus.SelectedItem.Text = "--Select--" AndAlso vendor.Status = ddsearchorderStatus.SelectedItem.Text) _
Or (Not txtSearchOrder.Text Is Nothing AndAlso vendor.Purchaseorderno = txtSearchOrder.Text) _
Or (Not ddsearchorderdate.Text = "--Select--" AndAlso vendor.Orderdate = ddsearchorderdate.Date) _
Select vendor.Purchaseorderno
For Each a In query
listpurchaseorder.Items.Add(a)
listpurchaseorder.DataTextField = "Purchaseorderno"
listpurchaseorder.DataValueField = "ID"
listpurchaseorder.DataBind()
Next
SerachCriteriaPartNo()
End Sub
谢谢