If you had a filled IQueryable variable.
How would you add a new empty entry in the end of that list?
Here is what I have to do:
- if there is 2 entry, add 3 empty entry
- if there is 0 entry, add 5 empty entry
- if there is 5 entry, add 5 empty entry
You can now see the pattern and it’s for a repeater in asp.net.
Should I simply create a generic list(.toList()) and use the add functionality or is there any better way to do this?
Well, if you’re happy to convert it to
IEnumerable<T>you can useNote that that will add the same extra row 5 times (and then cut the total down to 5). That won’t work if you need to then be able to edit the rows; to do that, you’d want something like:
(I don’t think there’s a simpler way of calling the same function
ntimes, but I could be wrong.)EDIT: I’ve added the call to
AsEnumerable()on the basis of comments. Basically callingAsEnumerablemeans “I’ve finished the SQL bit; do the rest in-process.”