I want to convert List<Object>
to List<U>
where as U
is the type that can be generated Dynamically but List is not accepting U
in C#
问问题
80 次
If you're only sending a few values in your delimited strings, I would suggest simply using the proper datatypes and calling the stored procedure a few times with individual values.
If, however, your delimited strings might contain hundreds or thousands of discrete values, then calling a proc that many times could be costly in terms of performance, especially if you can't send them all in one batch (I'm sure you want to use parameters rather than a giant concatenated command). If this is the case, you have a few options:
- Use Table Valued Parameters. This is like passing arrays as arguments to your proc.
- Pass XML to your proc, then shred and process it within the procedure.
- Insert your data to staging/temp tables, then call the procedure to operate on those tables.
- Take a step back and see if it makes sense to do more processing in your app. DB code usually doesn't scale nearly as well as app code.
- Send these delimited strings to your proc, split/parse them, then loop over the results in SQL. This seems to be what you're asking about and is possibly the least elegant option, even though it's one of the more popular ways to abuse a relational database.