please share the right LINQ query where i can also mention column name in where with other condition. thanks
It works just like any other column you're querying. I don't understand what the issue is here.
//Handle DbNull here...
&& (!x.IsDBNull("Deutsche Bank") && x.Field<decimal>("Deutsche Bank") == ??)
Personally it sounds to me like you want the value back. All the rows in your table have a column with this name so unless you want to filter out rows that have values in a range for this column then the where clause isn't useful here. Perhaps you want to filter out any row that doesn't have a value in this column, that's a standard null check.
&& !String.IsNullOrEmpty(x.Field<string>("Deutsche Bank"))
To get the value from the table just use the column name there as well.
//Assuming you have already filtered out the nulls...
foreach (var row in ds.Tables[2].Rows.OfType<DataRow>())
{
var bankAmount = row.Fields<decimal>("Deutsche Bank");
}
Now tell me how could i add one more clause in where condition that broker name.
Not sure what you mean here but I'm going to guess you want to be able to filter on Deutsche Bank
or Goldman
or one of those other columns but you want to decide at runtime. In that case instead of using a string literal for the column name, move to a string variable and programmatically determine which one you want to use.
string brokerName = "Deutsche Bank"; //Picking one at random, use your own logic to get the right one
//Remaining code remains unchanged inside linq
&& !x.IsDBNull("brokerName")
//Same for later in code
foreach (var row in ds.Tables[2].Rows.OfType<DataRow>())
{
var bankAmount = row.Fields<decimal>(brokerName);
}