Domanda

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!

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top