Hi OurTeam,
I have an issue while developing my project using Linq.
In BackEnd:
in my database i have one table 'Table1', in this table i have two columns
Column name Datatype
Name nvarchar(10)
Status char(1)
in my table i have below
Name Status
Mango E
Orange X
In Front End:
I have One Textbox 'TxtEntry' and Button 'BtnSave' after Entering 'Orange' in 'TxtEntry' and click on 'BtnSave' i want to check whether the Name exist or not using below query.
public string ExistOrNot(string Fruit,string Chkvalue)
{
using (DataContext dc = new DataContext())
{
var Existvalue = (from ExistData in dc.Table1.AsEnumerable()
where ExistData.Frmt_Id == Name && ExistData.Status != 'E'
select ExistData.Name.ToString()).FirstOrDefault();
if (Existvalue != null)
{
return Chkvalue = "1";
}
}
return Chkvalue = "2";
}
by using above query i am not getting value but if i am using "&& ExistData.Status == 'E'" i am getting value but it is not satisfied my requirement. in simple words , if the Name - status value is != 'E' then i want return value else not return any value. please help me