Compartir a través de


in ("M" Keywords)

[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]

The in operator asserts that an element is a member of a collection. Note that asserting that an element is a member of a collection is different from asserting that a collection is a subset of another collection. For the latter case, use the <= operator.

Syntax

element in collection

Examples

A common use of in is with constraints, as shown in the following example.

module M
{
    type A 
    {
        id : Integer32;
         x : Integer32; 
    } where identity id;
    
    type B 
    {
        id : Integer32; 
        singleA : A; 
    } where identity id;
  
    As : A*;
    
    Bs : (B where value.singleA in As)*;
}

This constraint asserts that the value of the singleA field in every member of Bs must be a member of the As collection.

You can also use a membership constraint to assert membership in a type, as seen in the following example.

type Category { 
    Name; 
    Description; 
} 
type Category3 : Category where value.Name in Text && value.Description in Text; 

In Microsoft code name “M”, a type is the set of values that conform to the type’s definition. In the preceding example, the in operator constrains the untyped fields in Category to be members of the intrinsic Text type.

See Also

Concepts

where ("M" Keywords)