Hi all,
in my query i have one table with following columns
Table Name: TstingTbl
SNo int IDENTITY(1,1) NOT NULL,
EntryName nvarchar(10),NOT NULL
in front of the page, i have one textbox(Name) and button(Save) . whenever i click button i want to check whether the name exist or not using linq query.
if the value exist then return the value or if it is not returning any value it returns empty data.
i tried below query. it returns the value but i want more efficient query.
string dtStatus;
string Name=TxtEntrNm.Text;
DataContext DC = new DataContext();
List<string> lstResult = (from table in DC.TstingTbl.AsEnumerable()
where table.EntryName == Name
select table.EntryName).ToList();
if (lstResult.Count == 0)
{
dtStatus = "";
}
else
{
dtStatus = lstResult[0];
}
return dtStatus;