我创建了一个捣鼓你here
我会建议你做客户端验证也是如此。 我假设你的日期列表是为了,所以第i个开始和结束日期的元素将代表第i个区间,因此只要日期是订单东西的
//Checking to make sure all effective dates have end date, except the last one.
for (var i = 1; i < effectiveEndDates.Count; i++)
{
if (!effectiveEndDates[i - 1].HasValue)
{
result = "cannot have a previous billing address without and end date.";
}
}
//Ensure all the startDates Dates are on or after the next end Date
//This solution will work if the effective dates are in order.
for (var i = 1; i < effectiveStartDates.Count; i++)
{
var effectiveEndDate = effectiveEndDates[i - 1];
if (effectiveEndDate != null && effectiveEndDate.Value > effectiveStartDates[i])
{
result = "cannot have 2 active billing address.";
}
}
行会做的伎俩(如生效日期)。希望这可以帮助
更新:我更新了小提琴,以确保没有任何重叠的无限范围。 [检查这个](https://dotnetfiddle.net/nmyA3P)
你有效的地址日期为了 – SadiRubaiyet