I currently have multiple methods that do pretty much the same thing but just query different tables.
I am trying to use only one method and pass the method parameters instead so i can skip creating multiple methods and neaten my code.
This is what i have currently:
MyEntityModel entity = new MyEntityModel();
private void loadData()
{
var query = from data in entity.Table1
select data;
myDataGrid.ItemsSource = query.ToList();
}
I want something like this:
MyEntityModel entity = new MyEntityModel();
private void loadData(DataGrid dataGrid, Table myTable )
{
var query = from data in entity.myTable
select data;
dataGrid.ItemsSource = query.ToList();
}
I'm unsure what Type parameter i should pass for myTable
I tried passing it as a System.Data.Entity.DbSet
and as a MyEntityModel
Is something like this even possible using LINQ?