public async Task <TEntity> FindSingleAsync(string where) { return(await Task.Run(() => { DataRow row = null; if (_table.dataTable != null) { // Is the record already in the dataTable row = _table.dataTable.Select(where).SingleOrDefault(); } if (row == null) { // record not in current datatable, requery data source, _table.sqlWhere(where); _table.getDataTable(); if (_table.dataTable == null) { return null; } if (_table.dataTable.Rows.Count > 0) { row = _table.dataTable.Rows[0]; } } if (row != null) { return _table.GetItem(row); } return null; })); }