I want to join 2 tables using EF and check if there is any value
public bool IsSubscriptionExist(string domain)
{
try
{
using (AccContext db = new AccContext ())
{
var count = (from s in db.Subscriptions
join a in db.Allias on s.Id equals a.Subscription_Id
where (s.Domain == domain || a.Allias_Domain == domain)
select s).Count();
return count > 0;
}
}
catch (Exception ex)
{
customLogManager.Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
throw ex;
}
}
The problem is that count returns 0 while subscription record is exist, I think because Allias is not exist. This is the same as join/left join I believe.
Is there any way to count even if Allias not exist ?
DefaultIfEmptyINNER JOIN, look up how to do aLEFT JOINwith entity framework