I'm not quite sure how to ask this. Given this code:
Dim newPatient As New tblPatientDemographic() With { _ .PatientName = txtPatientName.Text, _ .MedicalRecordNumber = CType(txtMedicalRecord.Text, Integer?) _ } _context.tblPatientDemographics.Add(newPatient) _context.SaveChanges()
it is possible that the medical record number can be blank. However, if left blank, then an error occurs that a string cannot be converted to integer. I understand this error but I don't know how to check if it is blank, and if so, then just ignore this.
Back when I was using winforms, I could do something like this:
.Parameters(10).Value = If(txtMedicalRecordNumber.Text = "", DBNull.Value, txtMedicalRecordNumber.Text)What would be the way to do this in WPF/EF?
Thanks.