我正在使用现有系统,需要通过存储过程添加报告。我只是想先解决一些错误。
在 IReportingRepository.cs 我有:
public interface IReportingRepository
{
IEnumerable<LastSundayDate<DateTime>> GetTradeMeKPISearches();
}
第一个错误在 LastSundayDate> 部分上方的行上,并说:非泛型类型“TradeUK.Entities.Reporting.LastSundayDate”不能与类型参数一起使用
我有一堂课 LastSundayDate.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TradeUK.Entities.Reporting
{
public class LastSundayDate
{
public virtual DateTime Date { get; set; }
}
}
在 ReportingServies.cs 我有:
public IEnumerable<LastSundayDate> GetTradeUKKPISearches()
{
return ReportingRepository.GetTradeUKKPISearches();
}
然后在 ReportingRepository.cs 我有:
public IEnumerable<LastSundayDate<DateTime>> GetTradeMeKPISearches()
{
try
{
using (SqlConnection conn = new SqlConnection(TradeUKModelContainer.CONNECTIONSTRING))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "[Reporting].[GetTradeMEKPISearches]";
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
da.Fill(dt);
List<LastSundayDate<DateTime>> results = new List<LastSundayDate<DateTime>>();
foreach (DataRow dr in dt.Rows)
{
string title = dr["Title"].ToString();
int count = Convert.ToInt32(dr["Total"]);
results.Add(new LastSundayDate<>());
}
}
}
}
}
catch (Exception ex)
{
throw new Exception("ReportingRepository GetTradeUKKPISearches: Error", ex);
}
}
为什么我不能将类型设置为 DateTime?谢谢