Hi,
I've embedded a fairly simple example of an issue we have in the greater solution.
The Context:
Using a datatable as the source.
Adding a summary row for Hours (Int32)
Get the error:No method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied arguments.
The last issue I had with datasets had a fairly simple fix. Hope this is the same.
Regards,
Nic Roche
I've embedded a fairly simple example of an issue we have in the greater solution.
The Context:
Using a datatable as the source.
Adding a summary row for Hours (Int32)
Get the error:No method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied arguments.
<Window x:Class="Window1" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" |
xmlns:telerikdata="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data" |
Title="Window1" WindowState="Maximized"> |
<Grid> |
<telerik:RadGridView |
AutoGenerateColumns="False" |
HorizontalAlignment="Right" |
IsFilteringAllowed="False" |
CanUserFreezeColumns="False" |
CanUserReorderColumns="False" |
IsEnabled="True" |
ColumnsWidthMode="Auto" |
ShowColumnFooters="True" |
CanUserSortColumns="False" |
ShowGroupPanel="False" |
ItemsSource="{Binding Tables[Labour.EmployeeLeave]}" |
> |
<telerik:RadGridView.Columns> |
<telerik:GridViewComboBoxColumn |
Header="Employee" |
DataMemberBinding="{Binding [EmpNum], Mode=TwoWay}" |
SelectedValueMemberPath="EmpNum" |
DisplayMemberPath="Fullname" |
ItemsSource="{Binding}" |
DataContext="{Binding Tables[Labour.Employee]}"/> |
<telerik:GridViewDataColumn Header="Leave Type" UniqueName="LeaveCode" /> |
<telerik:GridViewDataColumn Header="Date From" UniqueName="DateFrom" /> |
<telerik:GridViewDataColumn Header="Date To" UniqueName="DateTo" /> |
<telerik:GridViewDataColumn |
Header="Hours" |
DataMemberBinding="{Binding [Hours], Mode=TwoWay}" > |
<telerik:GridViewDataColumn.AggregateFunctions> |
<telerikdata:SumFunction Caption="Total: " SourceField="Hours" /> |
</telerik:GridViewDataColumn.AggregateFunctions> |
</telerik:GridViewDataColumn> |
<telerik:GridViewDataColumn Header="Pay In Advance" UniqueName="PayInAdvance"/> |
<telerik:GridViewDataColumn Header="Comments" UniqueName="Comments" /> |
<telerik:GridViewDataColumn Header="Total Made" UniqueName="TotalMade" /> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
</Grid> |
</Window> |
Imports System.Data |
Class Window1 |
Public Sub New() |
InitializeComponent() |
Dim ds As New DataSet |
Dim dt As New DataTable("Labour.Employee") |
Me.BuildEmployeesTable(dt) |
ds.Tables.Add(dt) |
dt = New DataTable("Labour.EmployeeLeave") |
Me.BuildEmployeeLeaveTable(dt) |
ds.Tables.Add(dt) |
Me.DataContext = ds |
End Sub |
Private Sub BuildEmployeesTable(ByVal dt As DataTable) |
dt.Columns.Add("EmpNum", GetType(System.Int32)) |
dt.Columns.Add("Firstname", GetType(System.String)) |
dt.Columns.Add("Surname", GetType(System.String)) |
dt.Columns.Add("Fullname", GetType(System.String), "Firstname+' '+Surname") |
Me.AdddEmployeesRow(dt, 1, "Joe", "Blogs") |
Me.AdddEmployeesRow(dt, 2, "John", "Doe") |
Me.AdddEmployeesRow(dt, 3, "Mary", "May") |
End Sub |
Private Sub BuildEmployeeLeaveTable(ByVal dt As DataTable) |
dt.Columns.Add("EmpNum", GetType(System.Int32)) |
dt.Columns.Add("LeaveCode", GetType(System.String)) |
dt.Columns.Add("DateFrom", GetType(System.DateTime)) |
dt.Columns.Add("DateTo", GetType(System.DateTime)) |
dt.Columns.Add("Hours", GetType(System.Int32)) |
dt.Columns.Add("PayInAdvance", GetType(System.Boolean)) |
dt.Columns.Add("Comments", GetType(System.String)) |
dt.Columns.Add("TotalMade", GetType(String), "Comments+Hours") |
Me.AdddEmployeeLeaveRow(dt, 1, "sss", Now, Now, 55, True, "comment") |
Me.AdddEmployeeLeaveRow(dt, 2, "sss", Now, Now, 22, True, "comment") |
Me.AdddEmployeeLeaveRow(dt, 3, "sss", Now, Now, 33, True, "comment") |
End Sub |
Private Sub AdddEmployeesRow(ByVal dt As DataTable, ByVal id As Integer, ByVal fname As String, ByVal lname As String) |
Dim dr As DataRow = dt.NewRow() |
dr("EmpNum") = id |
dr("Firstname") = fname |
dr("Surname") = lname |
dt.Rows.Add(dr) |
End Sub |
Private Sub AdddEmployeeLeaveRow(ByVal dt As DataTable, ByVal id As Integer, ByVal LeaveCode As String, ByVal DateFrom As DateTime, ByVal DateTo As DateTime, ByVal Hours As Integer, ByVal PayInAdvance As Boolean, ByVal Comments As String) |
Dim dr As DataRow = dt.NewRow() |
dr("EmpNum") = id |
dr("LeaveCode") = LeaveCode |
dr("DateFrom") = DateFrom |
dr("DateTo") = DateTo |
dr("Hours") = Hours |
dr("PayInAdvance") = PayInAdvance |
dr("Comments") = Comments |
dt.Rows.Add(dr) |
End Sub |
End Class |
The last issue I had with datasets had a fairly simple fix. Hope this is the same.
Regards,
Nic Roche