I need to write a linq query to check an ID is exist in sql table and If the ID is exist need to check one field is null or not in the same table.
I am new in entity framework ,please help.
Currently doing by like this:-
Here i am selecting by two methods,if the first method returns true i am checking the second method. Based on this value i need to enable/disable a tab.
public bool GetCompanyInfoById(int customerId)
{
using (var context = new eSmoEntities())
{
bool companyExist = context.tm_cmd_company_details.Any(x=>x.com_id.Equals(customerId));
return companyExist;
}
}
public bool GetGroupForCompany(int customerId)
{
using (var context = new eSmoEntities())
{
var customer = context.tm_cmd_company_details.Where(x => x.com_id == customerId).Select(x=>x.cmd_group_id).FirstOrDefault();
return customer != null ? true : false;
}
}
where new {x.A, x.B} equals new {y.A, y.B}