Imports Telerik.OpenAccess
Imports NorthwindDal
Imports Telerik.OpenAccess.Query
Imports System.Linq

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        Dim scope As IObjectScope = NorthwindDal.ObjectScopeProvider1.GetNewObjectScope()

        Dim StartDate As DateTime = DateTime.Now.AddDays(-45)
        Dim result = From p In scope.Extent(Of Order)() Where (p.ShippedDate.Value < StartDate) Order By p.ShippedDate Descending Select p

        RadGrid1.DataSource = result.ToList().Select(Function(order) New With {.Id = order.OrderID, .FormattedDate = New DateTime(order.ShippedDate.Value.Year, order.ShippedDate.Value.Month, order.ShippedDate.Value.Day)})

    End Sub

End Class
