<?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="Territory">
    <EntityType.Methods>
      <EntityMethod
        Name="Delete">
        <EntityMethod.Attributes>
          <Generated />
        </EntityMethod.Attributes>
      </EntityMethod>
    </EntityType.Methods>
    <EntityType.Properties>
      <KeyProperty
        Name="TerritoryID"
        PropertyType=":String">
        <KeyProperty.Attributes>
          <Required />
          <MaxLength
            Value="20" />
        </KeyProperty.Attributes>
      </KeyProperty>
      <EntityProperty
        Name="TerritoryDescription"
        PropertyType=":String">
        <EntityProperty.Attributes>
          <Required />
          <MaxLength
            IsFixedLength="True"
            Value="50" />
        </EntityProperty.Attributes>
      </EntityProperty>
      <NavigationProperty
        Name="EmployeeTerritories"
        Association="FK_EmployeeTerritories_Territories"
        FromEnd="Territories"
        ToEnd="EmployeeTerritories" />
      <NavigationProperty
        Name="Region"
        Association="FK_Territories_Region"
        FromEnd="Territories"
        ToEnd="Region" />
    </EntityType.Properties>
  </EntityType>
  <Association
    Name="FK_EmployeeTerritories_Territories">
    <AssociationEnd
      Name="EmployeeTerritories"
      Multiplicity="Many"
      EntityType="EmployeeTerritory" />
    <AssociationEnd
      Name="Territories"
      Multiplicity="One"
      EntityType="Territory">
      <AssociationEnd.Attributes>
        <DeleteRule />
      </AssociationEnd.Attributes>
    </AssociationEnd>
  </Association>
  <EntityContainer
    Name="NorthwindData">
    <EntityContainer.Attributes>
      <Partial />
    </EntityContainer.Attributes>
    <EntitySet
      Name="Territories"
      CanDelete="True"
      CanInsert="True"
      CanUpdate="True"
      EntityType="Territory" />
    <AssociationSet
      Name="FK_EmployeeTerritories_Territories"
      Association="FK_EmployeeTerritories_Territories">
      <AssociationSetEnd
        Name="EmployeeTerritories"
        EntitySet="EmployeeTerritories" />
      <AssociationSetEnd
        Name="Territories"
        EntitySet="Territories" />
    </AssociationSet>
    <QueryOperation
      Name="Territories_Single"
      ReturnType="Territory">
      <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="TerritoryID" />
              </ChainExpression>
            </BinaryExpression.Left>
            <BinaryExpression.Right>
              <ParameterExpression
                Parameter="TerritoryID" />
            </BinaryExpression.Right>
          </BinaryExpression>
        </QueryFilterExpressionTree>
      </QueryOperation.FilterExpression>
      <QueryOperation.Source>
        <QuerySourceExpressionTree>
          <MemberExpression
            Member="Territories" />
        </QuerySourceExpressionTree>
      </QueryOperation.Source>
      <QueryOperationParameter
        Name="TerritoryID"
        ParameterType=":String?">
        <QueryOperationParameter.Attributes>
          <Description
            Value="The value of the 'TerritoryID' key property of the entity to retrieve." />
        </QueryOperationParameter.Attributes>
      </QueryOperationParameter>
    </QueryOperation>
    <QueryOperation
      Name="Territories_SingleOrDefault"
      ReturnType="Territory">
      <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="TerritoryID" />
              </ChainExpression>
            </BinaryExpression.Left>
            <BinaryExpression.Right>
              <ParameterExpression
                Parameter="TerritoryID" />
            </BinaryExpression.Right>
          </BinaryExpression>
        </QueryFilterExpressionTree>
      </QueryOperation.FilterExpression>
      <QueryOperation.Source>
        <QuerySourceExpressionTree>
          <MemberExpression
            Member="Territories" />
        </QuerySourceExpressionTree>
      </QueryOperation.Source>
      <QueryOperationParameter
        Name="TerritoryID"
        ParameterType=":String?">
        <QueryOperationParameter.Attributes>
          <Description
            Value="The value of the 'TerritoryID' key property of the entity to retrieve." />
        </QueryOperationParameter.Attributes>
      </QueryOperationParameter>
    </QueryOperation>
  </EntityContainer>
  <DataService
    Name="NorthwindDataDataService">
    <DataService.Attributes>
      <Partial />
    </DataService.Attributes>
    <EntitySetMapping
      EntitySet="Territories">
      <EntitySetMapping.Attributes>
        <CsdlEntitySet
          EntityTypeName="Territory"
          EntityTypeNamespace="LightSwitchApplication"
          Name="Territories"
          EntityType="Territory" />
        <CsdlProperty
          Name="TerritoryID"
          Property="Territory/Properties[TerritoryID]" />
        <CsdlProperty
          Name="TerritoryDescription"
          Property="Territory/Properties[TerritoryDescription]" />
        <CsdlProperty
          Name="EmployeeTerritories"
          Property="Territory/Properties[EmployeeTerritories]" />
        <CsdlProperty
          Name="Region"
          Property="Territory/Properties[Region]" />
        <CsdlForeignKeyProperty
          Name="RegionID" />
      </EntitySetMapping.Attributes>
    </EntitySetMapping>
    <AssociationSetMapping
      AssociationSet="FK_EmployeeTerritories_Territories">
      <AssociationSetMapping.Attributes>
        <CsdlAssociation
          Name="FK_EmployeeTerritories_Territories"
          Association="FK_EmployeeTerritories_Territories" />
        <CsdlAssociationSetEnd
          End="NorthwindData/Members[FK_EmployeeTerritories_Territories]/Members[Territories]">
          <CsdlAssociationSetEnd.Attributes>
            <CsdlPropertyRef
              Name="TerritoryID" />
          </CsdlAssociationSetEnd.Attributes>
        </CsdlAssociationSetEnd>
        <CsdlAssociationSetEnd
          End="NorthwindData/Members[FK_EmployeeTerritories_Territories]/Members[EmployeeTerritories]">
          <CsdlAssociationSetEnd.Attributes>
            <CsdlPropertyRef
              Name="TerritoryID" />
          </CsdlAssociationSetEnd.Attributes>
        </CsdlAssociationSetEnd>
      </AssociationSetMapping.Attributes>
    </AssociationSetMapping>
  </DataService>
</ServiceApplication>