It seems that a table valued function must be "hard coded" to support the table defintion returned by the function.
This is done in two places:
1) The TableDefintion attribute
2) The method signature of the "fill method".
I have been told that 1) is not strictly required (used only by Visual Studio when deploying), but 2) seems to be necessary.
My question is, is there no way that the system, SQL Server and so on, can simply use reflection to deduce the "shape" of the returned items? This would allow us to write generic code that does not need to change if we change the structure of the data (for
example adding a field).
If we are forced to write a "fill" method with a dedicated signature, then this will be very much tied to the data and need tweaking every time we do anything to the data.
It would be very good if (for example) we could add an attribute to a field/property in our data (called [SqlMember("ID NVARCHAR(50)")] or something) that could then be used by SQL server to decuce the table defitition at runtime, it could easily do this
once using reflection to get the field type/name mappings and all that metadata would be in one place, in the class/struct defintion for the items.
Is there anything like this provided by SQL Server?
I don't see how I could even try to code that myself, because the "fill methid" a
View Complete Post