-
-
Notifications
You must be signed in to change notification settings - Fork 244
Description
Hi, I have written a Test project that uses the code below - and it works fine. I get back the correct # of records that contain the City == "Seatlle"...
However, in my main program this same code does not work. I have placed it in a few different places in the application - working on different tables - and I always get back a Count of Zero records.
Here is the code.... In all circumstances I have made sure there is a City field - and that there are records that contain the "Seattle" value.
private void barButtonItem_TestStuff_ItemClick(object sender, ItemClickEventArgs e)
{
// -------------------------------------------------------------
DataTable TempTable = dataSet_Results.Tables["a"];
string WhereClause = "City == @0";
var dynamicQueryb = TempTable.AsEnumerable().AsQueryable();
var dynamicQueryb2 = dynamicQueryb.Where(WhereClause, "Seattle").ToList();
MessageBox.Show("Total List Recs: " + dynamicQueryb2.Count.ToString());
// -------------------------------------------------------------
}If I use regular LINQ - such as
IEnumerable<DataRow> query =
from SelRec in SelRecsTable.AsEnumerable()
where SelRec.Field<String>("City") == "Seattle"
select SelRec;
DataTable boundTable = query.CopyToDataTable<DataRow>();
MessageBox.Show("Total Recs: " + boundTable.Rows.Count.ToString());
I get the right values. Here the Where clause works - and I get the right values. But if I use Dynamic LINQ - it always returns Zero - not the actual # of rows that contain "Seattle"
Any thoughts as to what might be causing this odd issue? At first I thought it might be my data - but I checked to make sure it had Seattle records - and then I tested it using just regular LINQ (and it works).
Any thoughts as to what I can do to try to troubleshoot this odd problem? Have anyone seen this happen before?
Bradley MacDonald