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!

Était-ce utile?

La 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);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top