Join Query using Entity FrameWork

In this article i am explaining how to use JOIN method in Entity Framework. Below is very simple and easy example. var query = db.Employee // source .Join(db.Salary, // target c => c.EmployeeID, // FK cm => cm.EmployeeID, // PK (em, sal) => new { Employee = em, Salary = sal }) // project result

Difference between firstordefault and singleordefault

Both are the element operators and they are used to select a single element from a sequence. But there is a minor difference between them. SingleOrDefault() operator would throw an exception if more than one elements are satisfied the condition where as FirstOrDefault() will not throw any exception for the same Single() – There is