In order to support the popular database, such as sqlserver, oracle and mysql, we changed the raw sql conditoin Query() method to GetList() method which are from the DapperExtension, but there will be a performance issue when using GetList(), it seemed it will do a full table read firstly rather than a sql query.
the sql query method:
TaskViewEntity taskView = null; string sql = @"SELECT * FROM vwWfActivityInstanceTasks WHERE ActivityInstanceID=@activityInstanceID AND ProcessInstanceID=@processInstanceID "; var list = Repository.Query<TaskViewEntity>(sql, new { processInstanceID = processInstanceID, activityInstanceID = activityInstanceID }).ToList();
The linq method:
var sqlQuery = (from tv in Repository.GetAll<TaskViewEntity>(conn, trans) where tv.ActivityInstanceID == activityInstanceID && tv.ProcessInstanceID == processInstanceID select tv ); var list = sqlQuery.ToList<TaskViewEntity>(); //The dapper extension GetList() method public IEnumerable<T> GetAll<T>(IDbConnection conn, IDbTransaction trans) where T : class { var dataList = conn.GetList<T>(null, null, trans); return dataList; }