When I run this code, I am checking that before I add a new record, there isn't already an existing one that matches the Bank account number, the VAT number or the Paypal email address...
But, if the Text boxes are empty, it is matching the first record that has an empty field in the database. eg. If txtBankAcctNum.text = "" it matches the first record in the db where there is no bank account number.
What I need it to do is only try matching the textbox.text to the db field if there is text present !
I'd be able to do this in a stored procedure, no problems, but I'm still learning this LINQ stuff. Can anyone help ?
billingDetail = db.BillingDetails.FirstOrDefault(bd => bd.BankAcctNum == txtBankAcctNum.Text.Trim()
|| bd.PayPalEmailAddress == txtPayPalEmailAddress.Text.Trim()
|| bd.VATnum == txtVATnum.Text.Trim());