I am using Linq for Entities. I have my main table, setting up Employee with a field named vendorID. Vendor ID is the foreign key in the Vendors table.
As of now, the Employee object does not directly expose the provider identifier. Instead, I can only access it like this:
var employee = (from e in context.Employees.Include("tbl_vendors")
where e.employeeID = 1
select e).FirstOrDefault();
int vendorID = employee.tbl_vendors.vendorID;
This is just fine and dandy, but it is an extra work on the database because it is a forced connection where there is no need. Is there a way to get this key value without having to make a connection to the tbl_vendors table?
source
share