Reputation: 1061
I'm querying the database and returning a row.
var p = (from prop in db.tabe
where prop.pid == 1
select prop);
However I'd like to take the result and insert that into a dataview. Is there a way?
Upvotes: 0
Views: 2292
Reputation: 3046
"Creating a DataView from a query that returns anonymous types or queries that perform join operations is not supported."
So that is not supported, why don't you use List instead:
var list = (from prop in db.tabe
where prop.pid == 1
select prop).ToList();
Upvotes: 4
Reputation: 14468
You could try:
DataView v = new p.AsDataView();
or
DataTable t = new DataTable();
foreach (DataRow dataRow in p)
t.Rows.Add(dataRow);
DataView v = new DataView(t);
Upvotes: 0
Reputation: 486
If you just want the result as a dataview you should be able to do this:
Dataview pDV = p.AsDataView();
This should be a full detail example and additional assistance:
http://msdn.microsoft.com/en-us/library/bb669073(v=vs.110).aspx
Upvotes: 1
Reputation: 434
You can do this:
DataView view = p.AsDataView();
bindingSource1.DataSource = view;
Upvotes: 1