Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
75
Problems binding LINQ queries to WinGrid
posted
Hi, I am attempting to bind a LINQ query to a WinGrid. Unfortunately, I keep getting exceptions when I try this. More details below!

var products = from row in dtProduct.AsEnumerable()
select new { Product = row.Field<string>("Description") };
ultraGridProducts.DataSource = product;


This simple query returns one column of strings. But when I try to bind it, I get the following exception:
The method or operation is not implemented.
Traced to:
System.Linq.Enumerable.Iterator`1.System.Collections.IEnumerator.Reset()

One may ask why I am using LINQ at all, why not just bind the DataTable and choose which columns I want to show? The answer is because the above query is the second query I tried and a much simpler version. The real query I am trying joins three datatables and eventually will dynamically filters the results. Here is the one I tried:

var products = from groupRow in dtGroup.AsEnumerable()
join linkRow in dtLink.AsEnumerable() on groupRow.Field<int>("LinkFID") equals linkRow.Field<int>("LinkUID")
join productRow in dtProduct.AsEnumerable() on linkRow.Field<int>("ProductFID") equals productRow.Field<int>("ProductUID")
select new
{
Product = productRow.Field<string>("Description"),
Group = groupRow.Field<string>("Description"),
ChangedAt = productRow.Field<DateTime>("ChangedAt"),
ChangedBy = productRow.Field<string>("ChangedBy"),
ProductUID = productRow.Field<int>("ProductUID"),
GroupUID = groupRow.Field<int>("GroupUID")
};

When I tried to bind that query, I got a null reference exception, traced to:
Infragistics.Win.UltraWinGrid.UltraGridBand.WireDataSource()
at Infragistics.Win.UltraWinGrid.UltraGridBand.InitListManager(BindingManagerBase bindingManager, String dataMember, UltraGridBand[ oldBands)
at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager)
at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated()

I'm puzzled first as to why two similar queries cause different exceptions to be thrown. The second one has joins. I've tried the first one with two columns instead of one and it still returns not implemented, so I don't think it is the number of columns (maybe 6 is significant). After the query returns, I've examined the results in both while debugging and they both look exactly correct, so I know the exception is being thrown when I try to bind the result to a WinGrid.DataSource.

Is there something I need to do to bind LINQ queries like this to WinGrid? I found a Infragistics tutorial that bound a LINQ to SQL class to a WinGrid. It looked easy and intuitive, just like what I'm trying to do here. But this doesn't work. However I'm obviously not using LINQ to SQL. I also tried binding products.AsEnumerable() with no luck.

I am using 2008 vol 3.

Thanks, I appreciate any help.
-Pete

P.S. sorry about the bad formatting. It looked a lot better in the window. I fixed it up a little bit anyway.