user3623300 user3623300 - 7 months ago 25
C# Question

Values in View and split a string

First off, I use this to get some kind of data from the database

string Query = "SELECT * FROM dbo.Person WHERE PersonId != @ID";
SqlParameter Parameter = new SqlParameter("@ID", ID);
IEnumerable<???> = db.Person.SqlQuery(Query, Parameter).ToList();

What should I return my result as a list of?

Then I just pass it along into my View right?

return View(???);

Should I edit my data before sending it to the view, or should I edit it in the View?

Because one of my values in the database is a value separated by semicolons


So I want to separate them, but how can I separate them, and if I separate in my controller, then how do I pass multiple values to the View?


The result can be anything as long as the type your return in the controller, is also implemented as Model in the View. The View receives this type. So return View(IEnumerable<Person>) should be fine.

I would suggest you edit the data in the model, but technically it doesn't matter. You can edit your data while looping through it in the view.