I am trying to debug the following line of code
binding.DataSource = this.bindingSource.DataSource;
and want to find out more information about binding.DataSource
In the immediate window the query ? binding.DataSource returns
Count = 1
[0]: {Contact Events}
I want to cast the binding.DataSource to something I can query with intellisense? What should I cast it to ?
[Update] The binding source was created as follows;
public BindingSource GetEventTypesBindingSource()
{
try
{
DbSet<ContactEventType> dset = base.Context.ContactEventTypes;
IOrderedQueryable<ContactEventType> qry = dset.Where(p => p.Id > 0).OrderBy(x => x.Description);
qry.Load();
var bindingSource = new BindingSource();
bindingSource.DataSource = dset.Local.ToBindingList();
return bindingSource;
}
catch (Exception ex)
{
HandleException.Show(ex);
}
return null;
}
[Update] I tried the following in the debugger
? (List<ContactEvent>) binding.DataSource.GetType()
but get
The type or namespace name 'List' is not valid in this scope
It's probably List<ContactEvent>
, but you can find out using the debugger and/or reflection.
If you view the variable in the Watch window of the debugger, it will show the type of the data. If you call GetType on the datasource it will return the type of the object (you can do this in the debugger too, and examine the resulting type there).