In my previous post I’ve used almost 2 million records to the check the grid performance in WPF and I’ve decided to do the same for Silverlight 4 using WCF RIA Services. The grid again is bound completely codeless using DomainDataSource and RadDataPager:
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<riaControls:DomainDataSource Name="orderDomainDataSource" QueryName="GetOrdersAndOrderDetails">
<riaControls:DomainDataSource.DomainContext>
<my:NorthwindDomainContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<telerik:RadGridView Name="RadGridView1" IsReadOnly="True" AutoExpandGroups="True"
ItemsSource="{Binding Data, ElementName=orderDomainDataSource}" />
<telerik:RadDataPager Grid.Row="1" PageSize="10"
Source="{Binding Data, ElementName=orderDomainDataSource}" DisplayMode="All" />
</Grid>
And the query again will return join between Northwind Orders and Order_Details:
…
public IQueryable<OrdersAndOrderDetails> GetOrdersAndOrderDetails() { var q = (from o in this.ObjectContext.Orders from od in this.ObjectContext.Order_Details select new OrdersAndOrderDetails() { OrderID = od.OrderID, ProductID = od.ProductID, UnitPrice = od.UnitPrice, Quantity = od.Quantity, Discount = od.Discount, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, OrderDate = o.OrderDate }).OrderBy(o=>o.OrderID); return q; } … public class OrdersAndOrderDetails
{ [Key, Display(AutoGenerateField=false)] public Guid ID { get { return Guid.NewGuid(); } } public int OrderID { get; set; } public int ProductID { get; set; } public decimal UnitPrice { get; set; } public short Quantity { get; set; } public float Discount { get; set; } public string CustomerID { get; set; } public int? EmployeeID { get; set; } public DateTime? OrderDate { get; set; } }
…
The grid operations like sorting, grouping and paging are applied directly to the server and only page-size data are returned!
Enjoy!
Vladimir Enchev is Director of Engineering, Native Mobile UI & Frameworks