Question

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!

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top