public static bool IsHoliday(this DateTime date)
{
mySqlCommand.CommandType = CommandType.Text;
mySqlCommand.CommandText = "Select date from HolidayTable”
SqlDataReader sqlreader = mySqlCommand.ExecuteReader();
List<DateTime> holidays = new List<DateTime>();
while (sqlreader.Read())
{
list.Add(reader.GetDateTime(0));
}
holidays.ToArray();
return holidays.Contains(date.Date);
}
我将如何从我的数据库中加载假期?
替换这个硬代码。
DateTime[] holidays =
new DateTime[] {
new DateTime(2013,12,27),
new DateTime(2013,12,28)};
它将添加到已在 AddWorkDays() 上排除星期日和星期六的 DateTimeExtensions