Trying to write a DALINQ expression where certain “where” parameters may or may not be needed or entered by the user. Is this valid? The “User*” vars are Boolean and indicate if the user has entered a value to used to query the table.
Is this proper LINQ to use in this situation?
var iq := from irec in fDatamodule.DataAdapter.GetTable<lpv8oelib.Data.invhistd>
where ((irec.ClassCode='8001') or (irec.ClassCode='8002') or (irec.ClassCode='8003') or (irec.ClassCode='8045'))
where ((irec.InvoiceDate>=d1) and (irec.InvoiceDate<=d2))
// conditional stuff???
where ((UserPub) or (irec.PubNumber=PubText.Text.Trim))
where ((UserClient) or (irec.ClientNum=ClientText.Text.Trim))
where ((UserAE) or (irec.AENumber=AdExecText.Text.Trim))
where ((UserClass) or (irec.Classcode=ClassText.Text.Trim))
// end of conditional
select new class(irec.MillerAd8,irec.AdYear4,irec.ClientNum,irec.ClientName,irec.ClassCode,irec.AENumber,irec.BSSCompany,irec.InvoiceNumber,
irec.InvoiceDate,irec.GrossAmount,irec.InvoiceType,irec.FirstInsDate,irec.LastInsDate,irec.PubName,irec.PubNumber);