确保验证范围值不与sql-server和C#的现有范围重叠

时间:2019-02-26 07:36:12

标签: c# sql sql-server

我在数据库中以from_amountto_amount的形式存储了一些范围信息,如下所示,

https://i.stack.imgur.com/I7rpA.png

public List<int> CheckRange(decimal from, decimal to)
{
    var rets = new List<int>();

    // Check From Amount
    if (Entity.amount.Any(x => x.to_amount >= from))
        rets.Add(1);

    // Check To Amount
    if (Entity.amount.Any(x => x.from_amount <= to))
        rets.Add(2);           
    return rets;
}

1 个答案:

答案 0 :(得分:1)

使用@if($match->schedule > $match->schedule) &nbsp;<strong id="match_schedule">Match will start soon</strong> @endif 方法尝试这种情况:

$ConnectArgs = @{
 ConnectionEndpoint = "mycluster:19000";  
 X509Credential = $True;  
 StoreLocation = 'CurrentUser';  
 StoreName = "MY"; 
 FindType = 'FindByThumbprint';  
 FindValue = "My_thumbprint"
 }
Connect-ServiceFabricCluster @ConnectArgs 
Get-ServiceFabricApplicationHealth -ApplicationName fabric:/Myapp -ExcludeHealthStatistics 

前两个条件确保没有边界在给定范围内,因此当一个范围包含在另一个范围内时,它仅留下一个选项,但是第三个条件检查(显然,条件检查与我说的相反,即为什么一开始就否定)。

注意:您可能想将$health = Get-ServiceFabricApplicationHealth -ApplicationName "fabric:/Myapp" If ($health.AggregatedHealthState -eq "OK") { Write-Host "$($clusterApplication)'s health is ok!" } Else { Write-Error "$($clusterApplication)'s health is not ok" } Where运算符更改为.Where(e => !((e.from_amount > from && e.from_amount < to) || (e.to_amount > from && e.to_amount < to) || (e.from_amount < from && e.to_amount > to))); <