Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the below code can't able to insert the value into the table
C#
public ActionResult Invite(string txt_inviteemail)
{
     E2EEntities1 entities = new E2EEntities1();
    E2E_Mstuserdetails userdetails = new E2E_Mstuserdetails();

    var validuser = entities.E2E_Mstuserdetails.Select(email => email.email).ToList();
    //string valid = validuser[0].ToString();

    foreach (string vEmail in validuser)
    {
        if (vEmail != txt_inviteemail)
        {
            userdetails.email = txt_inviteemail;
            //entities.E2E_Mstuserdetails.Add(userdetails.email);
           
            entities.E2E_Mstuserdetails.Add(userdetails);
            
            entities.SaveChanges();
        }
    }
Posted
v3
Comments
What is the issue? Did you debug?
George Swan 9-Mar-15 13:03pm    
It looks to me like you need to create a new E2E_Mstuserdetails object inside the 'if' statement.
entities.E2E_Mstuserdetails.Add(new E2E_Mstuserdetails{email=txt_inviteemail});

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900