Is it possible to set result of query directly to DataGrid (without mapping to object). I have some dynamic reports and I want to only display it in Grid, without set columns,etc.
Usually it'not problem because I "mapped" my data to an objects in model for example:
using (var db = new SQLiteConnection(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric(), "zakupy.db"))
{
listPerson = db.Table<Persons>().Where(x => x.Property == "P" && x.Status == 0).ToList();
}
lstPersons.DataContext = listPerson;
You need to map the results of the "select * from Events" query into an
IEnumerable
somehow.You could of course use an
SQLiteDataReader
and add anonymous objects to theItemsSource
. Something like this:I don't really see why you would want to do this instead of binding to a generic
IEnumerable<T>
though.Anyway, you can set or bind the
ItemsSource
of aDataGrid
orListView
to anyIEnumerable
. It doesn't really matter how you choose to populate this sequence as far as the control is concerned.