Compruebe la existencia de un registro antes de insertar un nuevo registro
Estoy usando Ado.net Entity Framework por primera vez y necesito verificar si este registro existe antes de insertarlo en la base de datos. Preferiblemente buscaría si AuthodSSID existe y no la clave (AuthorID). Estoy usando VS2010, Framework 4. System.Data.Entity es 3.5.0.0.
Busqué en Google, pero no encontré respuesta para esta pregunta.
PublishingCompanyEntities publishContext;
publishContext = new PublishingCompanyEntities();
private void createNew_Click(object sender, EventArgs e)
{
Author newAuthor = new Author();
newAuthor.FirstName = firstName.Text;
newAuthor.LastName = lastName.Text;
newAuthor.AuthodSSID = 20;
newAuthor.AuthorID = 10
//Check if record exist here
publishContext.AddToAuthor(newAuthor);//insert if does not exist
}