abe545 / CodeOnlyStoredProcedures

A library for easily calling Stored Procedures in .NET using only code (no xml or gui).
MIT License
4 stars 3 forks source link

Allow explicit casting of dynamic stored procedure results #22

Closed abe545 closed 9 years ago

abe545 commented 9 years ago

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) { }