Say I have this model:
public class Person
{
public int PersonId { get; set; }
[Required]
[MinLength(2)]
public string Name { get; set; }
[Phone]
public string PhoneNumber { get; set; }
[EmailAddress]
public string Email { get; set; }
}
but in my controller I want to add a temporary binding of data just to be passed once to a View such that:
Person.temp = new string();
and in each Person
object in my controller I can add a unique Person.temp
before it is sent to its view:
for (i = 0; i < 5; i )
{
Person per = new Person();
per.temp = "example" i;
per.PersonId = i;
per.Email = "[email protected]";
listofPersons.Add(per)
}
return(listofPersons)
CodePudding user response:
public class Person
{
public int PersonId { get; set; }
[Required]
[MinLength(2)]
public string Name { get; set; }
[Phone]
public string PhoneNumber { get; set; }
[EmailAddress]
public string Email { get; set; }
[NotMapped]
public string Temp {get;set;}
}
Have your tried marking it as NotMapped ?