I need to query the database row results is about 300,000 rows (growing).
The call is made from a controller in my main view ( MVC .net core) One of the columns comes in this format:
- [ ] The cat is black
- [ ] here is the change
- [G ] Some other text
I need to strip the [ ] or [G ]
Would I removed it at database level eg:
SELECT [Id]
,[Name]
,[Text] = Right([Text], LEN([Text]) - 8)
FROM MyDatabase
This seems incorrect – although it works – I have to put a magic number 8. What if this changes in the future? Developers insist in not having numbers that have no meaning?
Or do it in the controller :
viewModel.List = data.Select(val => new ViewModel
{
Id = val. Id,
Name = val.Name,
Text = val.Text.Substring(val.Text.IndexOf(']'))
}).ToList();
If you can shade some light or have a better idea I would appreciate it.