By default, explicitly casting a dynamic will not perform the dynamic conversion. This makes using the stored procedure more difficult. Consider the following:
// this works
IEnumerable<Item> items = connection.usp_foo();
// this throws an InvalidCastException
var items = (IEnumerable<Item>)connection.usp_foo();
This is important, because otherwise, you can't run code like this:
// this throws a bind exception
Act(connection.usp_foo());
// this throws an InvalidCastException
Act((IEnumerable<Item>)connection.usp_foo());
void Act(IEnumerable<Item> items) { }
By default, explicitly casting a dynamic will not perform the dynamic conversion. This makes using the stored procedure more difficult. Consider the following:
This is important, because otherwise, you can't run code like this: