Pergunta

How can you check in ASP.NET MVC Razor if a table row exists in de database? if the table row exists update it otherwise just add the object like the code below:

db.result.Add(object);

Thanks!

Foi útil?

Solução

use Linq to request

     `var data = (from record in db.result where record.field == yourInput select  record).FirstOrDefault();
     if (data == null)
     db.result.Add(object);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top