0

C# ASP.Net でレポートを作成しています。レポートでは、2 つの異なる日付 (たとえば、開始日: 7 月 15 日と終了日: 7 月 17 日) の間に作成されたデータをフィルター処理できますが、特定の日に作成されたデータのフィルター処理に関しては(たとえば、開始日: 7 月 15 日と終了日: 7 月 15 日) クエリは何も取得しません...

//Code from OutletDistributor.aspx.cs
ReportManager master = ObjectFactory.GetInstance<ReportManager>();
ReportResponse responce = new ReportResponse();
if (ddDistributor == Guid.Empty)
  responce = master.GetAllOutletDistributor(sDate, EDate);
else
  responce = master.GetOutletDistributor(sDate, EDate, ddDistributor);
ReportViewer1.Reset();
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
var stream = Assembly.GetAssembly(typeof(SampleReport)).GetManifestResourceStream(responce.ReportResource);
ReportDataSource reportDataSource = new ReportDataSource(responce.ReportDataSet, responce.ReportDataSource);
stream = RdlcReportHelper.TranslateReport(stream);
ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
ReportViewer1.LocalReport.LoadReportDefinition(stream);
ReportViewer1.LocalReport.DisplayName = ResourceHelper.GetText(null, "hq.rpt.outletdist.heading");
ReportViewer1.LocalReport.Refresh();

//Code from ReportManager.cs
//Filter All Outlet Distributor
public ReportResponse GetAllOutletDistributor(DateTime StartDate, DateTime EndDate) {
  ReportResponse report = new ReportResponse();
  report.ReportResource = "Distributr.HQ.Lib.Reports.RcdlFiles.OutletDistributor.rdlc";
  List<OutletReportItem> Report = _outletReport.GetAllOutlets()
    .Where(p => p.CreationDate >= StartDate && p.CreationDate <= EndDate).ToList();
  Report.ForEach(n => report.ReportDataSource.Add(n));
  report.ReportDataSet = "dsOutletDistributor";
  return report;
}
4

3 に答える 3

1

StartDateEndDate両方に時間要素が含まれていると思います。Dateプロパティを使用して削除します。

StartDate = StartDate.Date;
EndDate = EndDate.Date;

// your query goes here...
于 2012-07-26T09:58:30.937 に答える
0

実際にはList<OutletReportItem> Report = _outletReport.GetAllOutlets().Where(p => p.CreationDate >= StartDate && p.CreationDate <= EndDate).ToList()、オブジェクトDateTimeを初期化するときのコードであるため、日付のデフォルト値は「00」である時間、分、秒です。したがって、DateTime.Compare()を使用できると思います

于 2012-07-26T10:09:19.553 に答える
0

日付が同じであるこの状態では、クエリで(違いではなく)「=」を使用します

于 2012-07-26T10:02:43.997 に答える