I’m writing a LINQ to SQL based repository where I want to allow a GetByID with an int parameter. The signature is:
public T GetByID(int id)
{
// Return
return _dataContext.GetTable<T>() ....;
}
My tables have different names for the primary key. What I’d like to do is determine dynamically for each T what the primary key is and query it for a value of integer = id. Any ideas how to best pull this off?
Dennis Troller answered it to the question that Ben linked to in the comments in the question.