我正在填充以下 WPF 数据网格:
使用以下方法:
private void ButtonFilterWorkflowWhenClick(object sender, RoutedEventArgs e)
{
var db = new DatabaseHandle();
dataGridWorkflow.ItemsSource = db.DisplayHealthIndicator(DateTime.Now, DateTime.Now);
labelWorkflowLastLoaded.Content = "Last Loaded at " + DateTime.Now.ToString(CultureInfo.InvariantCulture) + " with " +
dataGridWorkflow.Items.Count.ToString(CultureInfo.InvariantCulture) + " total events.";
}
其中引用了以下类对象:
public DataView DisplayHealthIndicator(DateTime startDate, DateTime endDate)
{
string queryString = "[marlin].[support_retrieve_workflow_history]";
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
using (var cmd = new SqlCommand(queryString, connection))
{
connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("date_from", startDate.Date);
cmd.Parameters.AddWithValue("date_to", endDate.Date);
var reader = cmd.ExecuteReader();
var dt = new DataTable();
dt.Load(reader);
connection.Close();
return dt.DefaultView;
}
}
}
我正在尝试找到一种方法来找到总列的总和,以便将其添加到我的标签中,但没有成功。我可以通过第二个查询来做到这一点,但我想尽可能避免这种情况。我应该如何解决这个问题?