Hi! I use telerik RadGridView to display Sql-server data. There are a lot of records need to display therefore it is necessary to implement virtualization. We use Entity Framework and for this way work this method:
_collection = new VirtualQueryableCollectionView(uow.GetQueryableEntities<Cfo>().OrderBy(x => x.ID)) { LoadSize = 6, VirtualItemCount = 100 };
where Cfo - ef entity.
But it is necessary display data from tables which are absent in DbContext. I implement IDataReader for sql query. From dataReader I get column names and types, after this I create new Type dynamically and Map DataReader to IList of dynamically type objects:
_fields = DataReaderHelper.GetDataReaderRows(dr);
var dynamicClass = DynamicTypeBuilder.CreateNewObject(_fields);
var dataReaderList = DataReaderHelper.DataReaderMapToList(dr, dynamicClass.GetType());
In the end I get this:
_collection =
new
VirtualQueryableCollectionView(dataReaderList.AsQueryable()) { LoadSize = 6 };
But there is a problem: virtualization is not work! VirtualQueryableCollectionView make only one query, like: "Select *From dbo.[SomethingObjects]".
May be somebody know, how to solve this problem!
Ps: there is the second problem using VirtualQueryableCollectionView this ef entities: when grouping does not work virtualization!