DataGrid bind with Custom DataAdaptor excecute 4 times the same SELECT in SQL, i see that in SQL PROFILE.
This is de Razor page:
<EjsGrid @ref="DataGridS" TValue="Bookmark"
GridLines="GridLine.Default"
Toolbar="@(new List<string>() { "Search"})"
AllowSelection="true"
AllowPaging="true"
AllowResizing="true"
AllowExcelExport="true"
AllowPdfExport="true">
<GridPageSettings PageSize="20"></GridPageSettings>
<GridSelectionSettings Type="SelectionType.Single"></GridSelectionSettings>
<EjsDataManager AdaptorInstance="@typeof(BusinessAdaptorBookmark)" Adaptor="Adaptors.CustomAdaptor"></EjsDataManager>
<GridEvents TValue="Bookmark" OnActionFailure="@GridActionFailure" ContextMenuItemClicked="@GridDataOnContextMenuClick"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Bookmark.BookmarkId)
HeaderText="Id" IsPrimaryKey="true" Visible="false"></GridColumn>
<GridColumn Field=@nameof(Bookmark.Name)
HeaderText="Name"
Type="ColumnType.String"
Width="200px"></GridColumn>
<GridColumn Field=@nameof(Bookmark.Urlaction)
HeaderText="url"
Type="ColumnType.String"></GridColumn>
</GridColumns>
</EjsGrid>
CUSTOM ADAPTOR:
---
public class BusinessAdaptorBookmark : DataAdaptor
{
private EKSContext _context;
private IEnumerable _dataSource;
public BusinessAdaptorBookmark()
{
_context = (EKSContext)Eikon.ERPDataLayer.DataLayer.ContextCreator.Invoke(ERPDataLayer.DataSchemaEnum.EKS);
_dataSource = _context.Bookmark;
}
// Performs data Read operation
public override object Read(DataManagerRequest dm, string key = null)
{
if (dm.Search != null && dm.Search.Count > 0)
{
// Searching
_dataSource = DataOperations.PerformSearching(_dataSource, dm.Search);
}
if (dm.Sorted != null && dm.Sorted.Count > 0)
{
// Sorting
_dataSource = DataOperations.PerformSorting(_dataSource, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0)
{
// Filtering
_dataSource = DataOperations.PerformFiltering(_dataSource, dm.Where, dm.Where[0].Operator);
}
int count = _dataSource.AsQueryable().Count(); // .Cast<TEntity>().
if (dm.Skip != 0)
{
//Paging
_dataSource = DataOperations.PerformSkip(_dataSource, dm.Skip);
}
if (dm.Take != 0)
{
_dataSource = DataOperations.PerformTake(_dataSource, dm.Take);
}
return dm.RequiresCounts ? new DataResult() { Result = _dataSource, Count = count } : (object)_dataSource;
}
}
----
SQL PROFILE
---