Reputation: 8406
Edit: At first I thought this was related to component views, but I've managed to isolate the issue a bit.
I have the following class:
public class TmpContext
{
public NYPContext db { get; set; }
public IEnumerable<SelectListItem> GetUserListFromSelection(int[] selection)
{
var userList = from u in db.UsuariosIntranet
join su in selection on u.Id equals su
select new SelectListItem()
{
Text = string.Format("{0}, {1}", u.ApellidoPaterno, u.Nombres),
Value = u.Id.ToString(),
};
return userList;
}
}
I have a view that receives the class above as model, and have the following code in it:
@{
// First list
var list1 = new int[] { 4947850 };
var a = Model.GetUserListFromSelection(list1);
foreach (var user in a)
{
<p class="tag">@user.Text</p>
}
// Second list, note the different ids
var list2 = new int[] { 2, 3 };
var b = Model.GetUserListFromSelection(list2);
foreach (var user in b)
{
<p class="tag">@user.Text</p>
}
// Third list
var o = list1.ToList();
// add a new id
o.Add(5185969);
// int[] otra = ;
var c = Model.GetUserListFromSelection(o.ToArray());
foreach (var user in c)
{
<p class="tag">@user.Text</p>
}
}
The expected results are three different lists, but somehow I get the first items repeated three times.
Is this expected behaviour?
Upvotes: 2
Views: 533
Reputation: 8406
It appears to be a bug, and it is already fixed. Talk about fast turnaround!
https://github.com/aspnet/EntityFramework/issues/2826
Upvotes: 3