3
I have a list (IEnumerable
) called People that contains the properties Id, Datanasc, etc... I need to bring this data to a listview
in the html
using the Razor
(or it can be outside the cshtml page, in the . Cs files).
Let’s say person one has
Id 1, Date 23/03/2000;
And person 2 (displayed on the second lap of the foreach in the view) has:
Id 2, and Datanasc 23/03/2000;
Datanasc being equal in person 1 and 2...
I would like to make a consultation of the type: "if the value of the Datanasc property on the People list is the same for several people, return all those people who were born that same day".
Can someone help me?
I’m using C# Asp.Net MVC 4 with Razor View.
I’m new at C#, I was trying to do this, which stopping to think I think doesn’t make much sense, but I’m putting it to maybe try to illustrate what I wanted, although with the wrong logic.
@foreach (var item in Model.Pessoas)
{
for (int i = 0; i < Model.Pessoas.Count(); i++)
{
var arr = Model.Pessoas.ToArray();
if (item.DataNasc == arr[i].DataNasc)
{
<p>@arr[i].DataNasc</p>
}
}
}
if you have a list with these 5 dates: 23/03/2000; 23/03/2000; 30/01/2002; 10/02/2001;10/02/2001... what would be the intended output?
– vik
You want to make a grouping?
– Joy Peter