I have a generic repository an I am trying to add a GetById method as shown here C# LINQ to SQL: Refactoring this Generic GetByID method
The problem is my repository
try this
public virtual T GetByID(object id)
{
// Define the entity key values.
IEnumerable> entityKeyValues =
new KeyValuePair[] {
new KeyValuePair("Id", id) };
string qualifiedEntitySetName = _context.DefaultContainerName + "." + typeof(T).Name;
EntityKey key = new EntityKey(qualifiedEntitySetName, entityKeyValues);
return (T)_context.GetObjectByKey(key);
}