I want to locate an object that corresponds to a certain primary key and I have a table called "Customer" and its ORMapping Entity Customer in the entity framework.
instead of a query or lambda expression.
var Customer = from c in datacontext.Customer where c.CustomerID == your_key select c;
That is supposing that the CustomerID column in your customer database serves as the primary key.
Using the Find method of DbSet:
Customer customer= db.Customer.Find(your_key);
A lambda expression is used:
var customer= dataContext.Customer.Where(x=>x.CustomerID==your_key).FirstOrDefault();