开发者

Problem passing in Func as parameter to Where clause

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜