VirtualQueryableCollectionView Null reference exception when grouping columns in grid

4 posts, 1 answers
  1. Nicolai
    Nicolai avatar
    2 posts
    Member since:
    Aug 2015

    Posted 25 Aug 2015 Link to this post

    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)

    ...
  2. Answer
    Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 28 Aug 2015 Link to this post

    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.
  3. DevCraft banner
  4. Nicolai
    Nicolai avatar
    2 posts
    Member since:
    Aug 2015

    Posted 30 Aug 2015 in reply to Kristian Nikolov Link to this post

    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 :-(

  5. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 02 Sep 2015 Link to this post

    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.
Back to Top