Orm

LINQ to SQL: Create generic method to load entity by primary key

Scenario We are implementing our data access layer based on LINQ TO SQL. In the specifications that were created by our software architect is required to have generic method that load from the data base any record into entity object by primary key. public class LINQGateway<TEntity> where TEntity : class { private IDbConnection _DbConnection; public LINQGateway(IDbConnection connection) { this._DbConnection = connection; } public TEntity GetEntityByPrimaryKey(object pkKey, params object[] pkKeys) { // TO DO } } Problem Every table has different primary key (count, name and data type of the primary key columns).
Tags# , , ,