开发者

LINQ Query for Filter Result

Experts,

I have a datatable with two columns:

1) One is Decimal

2) One is String

I write my filter query like:

var iFilterResult = from c in dataTable1.AsEnumerable()
                                    where c.Field<string>("ACM_ACCOUNT_CODE").Contains(txtFindPrePaidExpenses.Text)
                                    && c.Field<string>("ACM_ACCOUNT_DESC").Contains(txtFindPrePaidExpenses.Text)
                                    select new
                                    {
                                        ACM_ACCOUNT_CODE = c.Field<string>("ACM_ACCOUNT_CODE"),
                                        ACM_ACCOUNT_DESC = c.Field<string>(" ACM_ACCOUNT_DESC")
                                    };
                gvSearchAccountGL.DataSource = iFilterResult;
                gvSearchAccountGL.DataBind();  "

Here 开发者_开发知识库dataTable1 is Datatable Having Column

ACM_ACCOUNT_CODE of decimal type

ACM_ACCOUNT_DESC of string type.

use like Query for filter.

But it is not working


You're trying to use ACM_ACCOUNT_CODE as a string field - but you've said it's a decimal field.

It's not clear why you'd expect a decimal field to contain the same value as the description field. If you really want this, you could use:

c.Field<decimal>("ACM_ACCOUNT_CODE")
 .ToString()
 .Contains(txtFindPrePaidExpenses.Text)

... but I suspect you should rethink what the query is trying to do.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜