Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that your query returns an <code>IEnumerable&lt;T&gt;</code> of an anonymous type and you can't simply cast that to a <code>EnumerableRowCollection&lt;DataRow&gt;</code></p> <p>I'm now sure which type of Grid you are using (e.g. from winforms? WPF? ASP? ASP MVC? etc), however I would expect that you should actually be able to pass it the IEnumerable output of the linq query if you wanted to - e.g.:</p> <pre><code>var query = (from item in Items.AsEnumerable() join grp in groups.AsEnumerable() on item.Field&lt;byte&gt;("Group_ID") equals grp.Field&lt;byte&gt;("ID") into item_grp_join from itemgrp in item_grp_join select new { ItemName = (string)led.Field&lt;string&gt;("Name"), GName = (string)itemgrp.Field&lt;string&gt;("Name"), }); grid.DataSource = query; // or possible query.ToList() as you suggest in the question! </code></pre> <p>If you really need to use a DataView type object, then there are blog posts about how to create these, try:</p> <ul> <li><a href="http://www.c-sharpcorner.com/UploadFile/VIMAL.LAKHERA/LINQResultsetToDatatable06242008042629AM/LINQResultsetToDatatable.aspx" rel="nofollow">http://www.c-sharpcorner.com/UploadFile/VIMAL.LAKHERA/LINQResultsetToDatatable06242008042629AM/LINQResultsetToDatatable.aspx</a></li> <li><a href="http://www.chinhdo.com/20090402/convert-list-to-datatable/" rel="nofollow">http://www.chinhdo.com/20090402/convert-list-to-datatable/</a></li> <li><a href="http://wpfguy.blogspot.com/2009/07/how-to-convert-ienumerable-to.html" rel="nofollow">http://wpfguy.blogspot.com/2009/07/how-to-convert-ienumerable-to.html</a></li> </ul> <p>Note that if you are expecting to use the grid for two-way binding (e.g. for writing changes back to the database), then this is unlikely to "just work" - as your IEnumerable projection isn't tied back to the datasource.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload