Pregunta

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!

¿Fue útil?

Solución

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 bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top