I have this simple 2 lines of following code. It compiles fine but never return results in the datagridview开发者_如何学C. If I change func to p=> p.PTNT_FIRST_NAME.StartsWith(this.textBox1.Text)
, it works just fine. What's the problem here?
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);
Change Func<PATIENT, bool>
to Expression<Func<PATIENT, bool>>
.
Try this:
Expression<Func<PATIENT, bool>> func = (PATIENT p) => p.PTNT_FIRST_NAME.StartsWith(this.textBox1.Text);
精彩评论