Udostępnij za pośrednictwem


Właściwość Checks

Reprezentuje kolekcja Check obiektów. Każdy Check obiekt reprezentuje ograniczenie typu check zdefiniowane w tabela.

Przestrzeń nazw:  Microsoft.SqlServer.Management.Smo
Zestaw:  Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)

Syntax

'Deklaracja
<SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(Check), SfcObjectFlags.Design)> _
Public ReadOnly Property Checks As CheckCollection
    Get
'Użycie
Dim instance As Table
Dim value As CheckCollection

value = instance.Checks
[SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(Check), SfcObjectFlags.Design)]
public CheckCollection Checks { get; }
[SfcObjectAttribute(SfcContainerRelationship::ChildContainer, SfcContainerCardinality::ZeroToAny, 
    typeof(Check), SfcObjectFlags::Design)]
public:
property CheckCollection^ Checks {
    CheckCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(Check), SfcObjectFlags.Design)>]
member Checks : CheckCollection
function get Checks () : CheckCollection

Wartość właściwości

Typ: Microsoft.SqlServer.Management.Smo. . :: . .CheckCollection
A Check obiekt, który reprezentuje wszystkie ograniczenia check, które są zdefiniowane w tabela.

Przykłady

Poniższy przykład kodu pokazuje sposób wyświetlania nazw każdego typu CHECK na każdym AdventureWorks2008R2 tabela.

C#

Server srv = new Server("(local)");
Database db = srv.Databases["AdventureWorks2008R2"];

foreach (Table tb in db.Tables)
{
   foreach (Check ck in tb.Checks)
   {
      Console.WriteLine("The " + tb.Name + " table has the " + ck.ToString() + " check.");
   }
}

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2008R2")

Foreach ($tb in $db.Tables)
{
   Foreach ($ck in $tb.Checks)
   {
      Write-Host "The" $tb.Name "table has the" $ck "check."
   }
}