Step 2: Define Entities, Methods, and Filters

A line-of-business (LOB) application registered in the Business Data Catalog defines the entities, the methods that can be executed on the entities, and filters to enable end-user filtering. An entity is a business object, such as Customer or Product, in an LOB application. Methods are the operations related to an entity, and filters help limit the entity instances returned from the method.

In the Business Data Catalog, an entity belongs to a single LOB system and must have a unique name. Entities contain identifiers, methods, filters, and actions.

In this step, you will define an entity called Products in the AdventureWorks2000 database, and define a method called GetProducts to get a list of products. You will also add wildcard and comparison filters to enable end-user filtering on the ID, Name, and ProductNumber fields.

Prerequisites

Step 1: Connect to the AdventureWorks2000 Database

To define an entity, method, and filters

  1. Open your AdventureWorks2000.XML metadata XML file from Step 1.

  2. Insert the following XML to replace the <!--Insert Entity XML Here --> section in that file:

    <Entity EstimatedInstanceCount="10000" Name="Product">
          <!-- EstimatedInstanceCount is an optional attribute-->
          <Properties>
            <Property Name="Title" Type="System.String">Name</Property>
          </Properties>
          <Identifiers>
            <Identifier Name="ProductID" TypeName="System.Int32" />
          </Identifiers>
          <Methods>
            <!-- Defines a method that brings back Product data from the 
            back-end database.-->
            <Method Name="GetProducts">
              <Properties>
                <Property Name="RdbCommandText" Type="System.String">
                  SELECT ProductID, Name, ProductNumber, ListPrice FROM Product WHERE (ProductID &gt;= @MinProductID) AND (ProductID &lt;= @MaxProductID) AND (Name LIKE @Name) AND (ProductNumber LIKE @ProductNumber)
                </Property>
                <Property Name="RdbCommandType" Type="System.Data.CommandType">Text</Property>
                <!-- For database systems, can be Text, StoredProcedure, 
                or TableDirect. -->
              </Properties>
              <FilterDescriptors>
                <!-- Define the filters supported by the back-end method 
               (or sql query) here. -->
                <FilterDescriptor Type="Comparison" Name="ID" >
                  <Properties>
                    <Property Name="Comparator" Type="System.String">Equals</Property>
                  </Properties>
                </FilterDescriptor>
                <FilterDescriptor Type="Wildcard" Name="Name">
                  <Properties>
                    <Property Name="UsedForDisambiguation" Type="System.Boolean">true</Property>
                  </Properties>
                </FilterDescriptor>
                <FilterDescriptor Type="Wildcard" Name="ProductNumber" />
              </FilterDescriptors>
              <Parameters>
                <Parameter Direction="In" Name="@MinProductID">
                  <TypeDescriptor TypeName="System.Int32" IdentifierName="ProductID" AssociatedFilter="ID" Name="MinProductID">
                    <DefaultValues>
                      <DefaultValue MethodInstanceName="ProductFinderInstance" Type="System.Int32">0</DefaultValue>
                    </DefaultValues>
                  </TypeDescriptor>
                </Parameter>
                <Parameter Direction="In" Name="@MaxProductID">
                  <TypeDescriptor TypeName="System.Int32" IdentifierName="ProductID" AssociatedFilter="ID" Name="MaxProductID">
                    <DefaultValues>
                      <DefaultValue MethodInstanceName="ProductFinderInstance" Type="System.Int32">99999999</DefaultValue>
                    </DefaultValues>
                  </TypeDescriptor>
                </Parameter>
                <Parameter Direction="In" Name="@Name">
                  <TypeDescriptor TypeName="System.String" AssociatedFilter="Name" Name="Name">
                    <DefaultValues>
                      <DefaultValue MethodInstanceName="ProductFinderInstance" Type="System.String">%</DefaultValue>
                      <DefaultValue MethodInstanceName="ProductSpecificFinderInstance" Type="System.String">%</DefaultValue>
                    </DefaultValues>
                  </TypeDescriptor>
                </Parameter>
                <Parameter Direction="In" Name="@ProductNumber">
                  <TypeDescriptor TypeName="System.String" AssociatedFilter="ProductNumber" Name="ProductNumber">
                    <DefaultValues>
                      <DefaultValue MethodInstanceName="ProductFinderInstance" Type="System.String">%</DefaultValue>
                      <DefaultValue MethodInstanceName="ProductSpecificFinderInstance" Type="System.String">%</DefaultValue>
                    </DefaultValues>
                  </TypeDescriptor>
                </Parameter>
                <Parameter Direction="Return" Name="Products">
                  <TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true" Name="ProductDataReader">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="ProductDataRecord">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="System.Int32" IdentifierName="ProductID" Name="ProductID">
                            <LocalizedDisplayNames>
                              <LocalizedDisplayName LCID="1033">ID</LocalizedDisplayName>
                            </LocalizedDisplayNames>
                          </TypeDescriptor>
                          <TypeDescriptor TypeName="System.String" Name="Name" >
                            <!-- Do not use the AssociatedFilter 
                            attribute in return parameters.-->
                            <LocalizedDisplayNames>
                              <LocalizedDisplayName LCID="1033">Name</LocalizedDisplayName>
                            </LocalizedDisplayNames>
                            <Properties>
                              <Property Name="DisplayByDefault" Type="System.Boolean">true</Property>
                            </Properties>
                          </TypeDescriptor>
                          <TypeDescriptor TypeName="System.String" Name="ProductNumber">
                            <LocalizedDisplayNames>
                              <LocalizedDisplayName LCID="1033">Product Number</LocalizedDisplayName>
                            </LocalizedDisplayNames>
                            <Properties>
                              <Property Name="DisplayByDefault" Type="System.Boolean">true</Property>
                            </Properties>
                          </TypeDescriptor>
                          <TypeDescriptor TypeName="System.Decimal" Name="ListPrice">
                            <LocalizedDisplayNames>
                              <LocalizedDisplayName LCID="1033">List Price</LocalizedDisplayName>
                            </LocalizedDisplayNames>
                          </TypeDescriptor>
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Name="ProductFinderInstance" Type="Finder" ReturnParameterName="Products" />
                <MethodInstance Name="ProductSpecificFinderInstance" Type="SpecificFinder" ReturnParameterName="Products" />
              </MethodInstances>
            </Method>
          </Methods>
          <!-- Enter your Action XML here -->
        </Entity>
    
  3. Save the XML file.

  4. Add the application definition to the Business Data Catalog. For details, see How to: Add an Application Definition to the Business Data Catalog.

  5. Test the metadata by creating a Business Data List Web Part, a Details Web Part, a Business Data column of Type, Product, or any combination of these. For details, see Testing the Metadata.

Next Steps

Step 3 (Optional): Define Actions

See Also

Tasks

AdventureWorks SQL Server 2000 Sample

Concepts

Business Data Catalog: Metadata Model