开发者

LINQ Query for Filter Result

开发者 https://www.devze.com 2023-03-03 18:25 出处:网络
Experts, I have a datatable with two columns: 1) One is Decimal 2) One is String I write my filter query like:

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

精彩评论

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