I need LINQ code to be able to detect if an entry is input but the datum already exists in the table.
public Boolean CheckAssessment(String assessmentName)
{
{
SQL_TA_SCOREBOARDEntities1 d = new SQL_TA_SCOREBOARDEntities1();
Assessment A_List = new Assessment();
{
var qry2 = from b in contxt.View_Assessment
where b.AssessmentName == assessmentName
select b;
if (qry2 = assessmentName.ToString())
{
return true;
}
else
{
return false;
}
}
}
}
Where assessmentName is the value of the textbox in the a separate C# class.
Boolean i;
i = TAClass.CheckAssessment(txtAssessmentName.ToString());
if (i == true)
{
Label2.Text = "Assessment name already exists.";
}
FirstOrDefaultextension) and 2) you need to selectb.AssessmentNamein linq code, otherwise it will return an object for you (and not a string)