如何选择列报告

时间:2016-06-19 12:49:11

标签: c# linq

我想选择要在报告中显示的列,使用以下代码:

 Database1Entities DBE = new Database1Entities();
 string FirstName = "";
 string LastName = "";
 if (checkBoxFirstName.IsChecked == true)
     FirstName = "c.First_Name";
 if (checkBoxLastName.IsChecked == true)
     LastName = "c.Last_Name";

 var search = from c in DBE.Tables
              where
              string.IsNullOrEmpty(textBoxFirstName.Text) || (textBoxFirstName.Text) == (c.First_Name)
              &&
              string.IsNullOrEmpty(textBoxLastName.Text) || (textBoxLastName.Text) == (c.Last_Name)
              select new { FirstName, LastName };
 dataGrid.ItemsSource = search.ToList();

但结果是:

enter image description here

在上面的代码中,我使用了两个变量FirstNameLastName。如果选中该复选框,则在要显示的报告中,但不起作用。

0 个答案:

没有答案