This is a migrated thread and some comments may be shown as answers.

VirtualQueryableCollectionView Null reference exception when grouping columns in grid

3 Answers 100 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nicolai
Top achievements
Rank 1
Nicolai asked on 25 Aug 2015, 11:29 AM
Hello,

I am using Telerik WPF RadGridView with Data Access ORM and data virtualization.

I bind my grid to virtualized collection, that I create with code similar to this:

collection = new VirtualQueryableCollectionView(context
 .GetAll("FluentModel.MyTable")
 .Select("new (id, p1, p2)")
 .OrderBy("id"))
{ LoadSize = 10 };


When I try to group data by a column in the grid, the data is being grouped, but expanding the group throws null reference exception:

An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.OpenAccess.35.Extensions.dll
Additional information: Object reference not set to an instance of an object.

If I remove "Select" clause from LINQ expression, it works good, so the exception appears only when I convert entity type to anonymous type.
In-memory scenario (converting IQueryable to List) also works.
SQL Profiler shows that sql query for expanded section has been queried just before the crash, and the query returns correct data.
Entity in FluentContext is mapped as artificial type.

Telerik Data Acces version is 2015.2.624.1

Stack Trace:

 at Telerik.OpenAccess.Query.TypedEnumerator`1.ObtainCurrent()
   at Telerik.OpenAccess.Query.TypedEnumerator`1.get_Current()
   at Telerik.OpenAccess.Query.CachingEnumerator`1.MoveNext()
   at Telerik.OpenAccess.Query.GroupingImpl`2.ResolveMemory()
   at Telerik.OpenAccess.Query.GroupingImpl`2.GetEnumerator()
   at Telerik.OpenAccess.Query.GroupingImpl`2.System.Collections.IEnumerable.GetEnumerator()
   at Telerik.Windows.Data.KeyedCollection.AddRange(IEnumerable items)
   at Telerik.Windows.Data.KeyedCollection..ctor(IEnumerable items, Func`2 keyFunction, Func`3 sortComparerFunc)
   at Telerik.Windows.Data.QueryableCollectionViewGroup.Load()
   at Telerik.Windows.Data.QueryableCollectionViewGroup.EnsureItems()
   at Telerik.Windows.Data.QueryableCollectionViewGroup.get_Items()
   at Telerik.Windows.Controls.GridView.QueryableCollectionViewGroupExtensions.GetRowItemsAtRange(QueryableCollectionViewGroup group, Int32 startIndex, Int32 rowItemsRemainingCount, Func`2 isGroupExpandedFunc, Boolean showGroupFooters, IDictionary`2 rowCountCache)
   at Telerik.Windows.Controls.GridView.QueryableCollectionViewGroupExtensions.GetRowItemsAtRange(QueryableCollectionViewGroup group, Int32 startIndex, Int32 rowItemsRemainingCount, Func`2 isGroupExpandedFunc, Boolean showGroupFooters, IDictionary`2 rowCountCache)
   at Telerik.Windows.Controls.GridView.Rows.GetRowItemsAtRange(Int32 startIndex, Int32 endIndex)
   at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.RealizeRows(Int32 startIndex, Int32 endIndex, Double& verticalOffset, HashSet`1& realizedRows)
   at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.MeasureOverride(Size availableSize)
   at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size availableSize)

...

3 Answers, 1 is accepted

Sort by
0
Accepted
Kristian Nikolov
Telerik team
answered on 28 Aug 2015, 08:23 AM
Hello Nicolai,

Thank you for contacting us.

We managed to reproduce the issue you have described. It appears that the reason for this is incompatibility between the VirtualQueryableCollection view and the a DataAccess query which results in anonymous type.

With this in mind we recommend you use the entity object itself without projecting it into anonymous type.

Alternatively, as a workaround you can define DTO type and modify System.Linq.Dynamic source code as described here, in order to be able to make projection into non anonymous types. You would be able to use a the following syntax:
VirtualQueryableCollectionView view = new VirtualQueryableCollectionView(context.GetAll("DEMO_VirtualizationCollectionArtificial.Product")
    .Select("new WpfApplication1.ProductDto(Id as Id, Name as Name)")
    .OrderBy("Id")) { LoadSize = 10 };
Note that the full name of the DTO type is used (including the namespace).
Using this approach we were able to group through a RadGridView without an error.

I hope this helps. Feel free to post at our forums again if you have any more questions.

Regards,
Kristian Nikolov
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
0
Nicolai
Top achievements
Rank 1
answered on 31 Aug 2015, 04:29 AM

Hello, Kristian,

Thank you for the response.Is there any chance that this will be fixed in future releases of DataAccess or VirtualQueryableCollectionView? It looks like a common scenario for artificial types, I'm using it for displaying attributes of joined tables, creating a new class for every dynamic query looks not very convinient :-(

0
Kristian Nikolov
Telerik team
answered on 02 Sep 2015, 02:38 PM
Hi Nicolai,

Thank you for your feedback. The behavior at hand is a result of an unsupported integration scenario between UI for WPF and Data Access. Implementing it is not in our schedule at the moment given there is an available workaround.

Do not hesitate to post at our forums again if you have any more questions.

Regards,
Kristian Nikolov
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
Development (API, general questions)
Asked by
Nicolai
Top achievements
Rank 1
Answers by
Kristian Nikolov
Telerik team
Nicolai
Top achievements
Rank 1
Share this question
or