Problem passing in Func parameter as Where parameter

I have this simple 2 lines of the following code. It compiles fine but never returns results in the datagridview. If I change func to p=> p.PTNT_FIRST_NAME.StartsWith(this.textBox1.Text)

, it works just fine. What is the problem?

Func<PATIENT, bool> func = (PATIENT p) => p.PTNT_FIRST_NAME.StartsWith(this.textBox1.Text);
this.dataGridView1.DataSource = dataContext.PATIENTs.Where<PATIENT>(func).Select(q => q);

      

+2


a source to share


2 answers


Change Func<PATIENT, bool>

to Expression<Func<PATIENT, bool>>

.



+2


a source


Try the following:



Expression<Func<PATIENT, bool>> func = (PATIENT p) => p.PTNT_FIRST_NAME.StartsWith(this.textBox1.Text);

      

+2


a source







All Articles