<?xml version="1.0" encoding="utf-8"?>
<ServiceApplication
  Name="LightSwitchServiceApplication" xmlns="http://schemas.microsoft.com/LightSwitch/2010/xaml/model">
  <ServiceApplication.Attributes>
    <Partial />
  </ServiceApplication.Attributes>
  <EntityType
    Name="Region">
    <EntityType.Methods>
      <EntityMethod
        Name="Delete">
        <EntityMethod.Attributes>
          <Generated />
        </EntityMethod.Attributes>
      </EntityMethod>
    </EntityType.Methods>
    <EntityType.Properties>
      <KeyProperty
        Name="RegionID"
        PropertyType=":Int32">
        <KeyProperty.Attributes>
          <Required />
          <NotSearchable />
        </KeyProperty.Attributes>
      </KeyProperty>
      <EntityProperty
        Name="RegionDescription"
        PropertyType=":String">
        <EntityProperty.Attributes>
          <Required />
          <MaxLength
            IsFixedLength="True"
            Value="50" />
        </EntityProperty.Attributes>
      </EntityProperty>
      <NavigationProperty
        Name="Territories"
        Association="FK_Territories_Region"
        FromEnd="Region"
        ToEnd="Territories" />
    </EntityType.Properties>
  </EntityType>
  <Association
    Name="FK_Territories_Region">
    <AssociationEnd
      Name="Region"
      Multiplicity="One"
      EntityType="Region">
      <AssociationEnd.Attributes>
        <DeleteRule />
      </AssociationEnd.Attributes>
    </AssociationEnd>
    <AssociationEnd
      Name="Territories"
      Multiplicity="Many"
      EntityType="Territory" />
  </Association>
  <EntityContainer
    Name="NorthwindData">
    <EntityContainer.Attributes>
      <Partial />
    </EntityContainer.Attributes>
    <EntitySet
      Name="Regions"
      CanDelete="True"
      CanInsert="True"
      CanUpdate="True"
      EntityType="Region" />
    <AssociationSet
      Name="FK_Territories_Region"
      Association="FK_Territories_Region">
      <AssociationSetEnd
        Name="Region"
        EntitySet="Regions" />
      <AssociationSetEnd
        Name="Territories"
        EntitySet="Territories" />
    </AssociationSet>
    <QueryOperation
      Name="Regions_Single"
      ReturnType="Region">
      <QueryOperation.Attributes>
        <Generated />
        <Description
          Value="Returns the entity whose identity is specified by the parameter(s)." />
      </QueryOperation.Attributes>
      <QueryOperation.FilterExpression>
        <QueryFilterExpressionTree>
          <BinaryExpression
            NodeType="Equal">
            <BinaryExpression.Left>
              <ChainExpression>
                <MemberExpression
                  Member="RegionID" />
              </ChainExpression>
            </BinaryExpression.Left>
            <BinaryExpression.Right>
              <ParameterExpression
                Parameter="RegionID" />
            </BinaryExpression.Right>
          </BinaryExpression>
        </QueryFilterExpressionTree>
      </QueryOperation.FilterExpression>
      <QueryOperation.Source>
        <QuerySourceExpressionTree>
          <MemberExpression
            Member="Regions" />
        </QuerySourceExpressionTree>
      </QueryOperation.Source>
      <QueryOperationParameter
        Name="RegionID"
        ParameterType=":Int32?">
        <QueryOperationParameter.Attributes>
          <Description
            Value="The value of the 'RegionID' key property of the entity to retrieve." />
        </QueryOperationParameter.Attributes>
      </QueryOperationParameter>
    </QueryOperation>
    <QueryOperation
      Name="Regions_SingleOrDefault"
      ReturnType="Region">
      <QueryOperation.Attributes>
        <Generated />
        <Description
          Value="Returns the entity whose identity is specified by the parameter(s) or null if no such entity exists." />
      </QueryOperation.Attributes>
      <QueryOperation.FilterExpression>
        <QueryFilterExpressionTree>
          <BinaryExpression
            NodeType="Equal">
            <BinaryExpression.Left>
              <ChainExpression>
                <MemberExpression
                  Member="RegionID" />
              </ChainExpression>
            </BinaryExpression.Left>
            <BinaryExpression.Right>
              <ParameterExpression
                Parameter="RegionID" />
            </BinaryExpression.Right>
          </BinaryExpression>
        </QueryFilterExpressionTree>
      </QueryOperation.FilterExpression>
      <QueryOperation.Source>
        <QuerySourceExpressionTree>
          <MemberExpression
            Member="Regions" />
        </QuerySourceExpressionTree>
      </QueryOperation.Source>
      <QueryOperationParameter
        Name="RegionID"
        ParameterType=":Int32?">
        <QueryOperationParameter.Attributes>
          <Description
            Value="The value of the 'RegionID' key property of the entity to retrieve." />
        </QueryOperationParameter.Attributes>
      </QueryOperationParameter>
    </QueryOperation>
  </EntityContainer>
  <DataService
    Name="NorthwindDataDataService">
    <DataService.Attributes>
      <Partial />
    </DataService.Attributes>
    <EntitySetMapping
      EntitySet="Regions">
      <EntitySetMapping.Attributes>
        <CsdlEntitySet
          EntityTypeName="Region"
          EntityTypeNamespace="LightSwitchApplication"
          Name="Regions"
          EntityType="Region" />
        <CsdlProperty
          Name="RegionID"
          Property="Region/Properties[RegionID]" />
        <CsdlProperty
          Name="RegionDescription"
          Property="Region/Properties[RegionDescription]" />
        <CsdlProperty
          Name="Territories"
          Property="Region/Properties[Territories]" />
      </EntitySetMapping.Attributes>
    </EntitySetMapping>
    <AssociationSetMapping
      AssociationSet="FK_Territories_Region">
      <AssociationSetMapping.Attributes>
        <CsdlAssociation
          Name="FK_Territories_Region"
          Association="FK_Territories_Region" />
        <CsdlAssociationSetEnd
          End="NorthwindData/Members[FK_Territories_Region]/Members[Region]">
          <CsdlAssociationSetEnd.Attributes>
            <CsdlPropertyRef
              Name="RegionID" />
          </CsdlAssociationSetEnd.Attributes>
        </CsdlAssociationSetEnd>
        <CsdlAssociationSetEnd
          End="NorthwindData/Members[FK_Territories_Region]/Members[Territories]">
          <CsdlAssociationSetEnd.Attributes>
            <CsdlPropertyRef
              Name="RegionID" />
          </CsdlAssociationSetEnd.Attributes>
        </CsdlAssociationSetEnd>
      </AssociationSetMapping.Attributes>
    </AssociationSetMapping>
  </DataService>
</ServiceApplication>