3.1 Database Model

This is an example of a simple model of an LOB system of type Database. It demonstrates how to use a set of LobSystem and LobSystemInstance properties to configure connection to a database.

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <Model Name="ExampleApplicationDefinition" xmlns="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog">
     <LobSystem Name="ExampleCRM" Type="Database">
         <!-- This database uses % symbol for the LIKE operator. -->
         <Property Name="WildcardCharacter" Type="System.String">%</Property>
         <LobSystemInstance Name="ExampleServer">
             <Property Name="AuthenticationMode" Type="System.String">PassThrough</Property>
             <!-- The database instance is named ExampleSQL and is running on the same computer as the application using this Model. -->
             <Property Name="RdbConnection Data Source" Type="System.String">(local)\ExampleSQL</Property>
             <!-- The database to be used is named ExampleDB. -->
             <Property Name="RdbConnection Initial Catalog" Type="System.String">ExampleDB</Property>
             <!-- The database instance is using integrated security. -->
             <Property Name="RdbConnection Integrated Security" Type="System.String">SSPI</Property>
         <Entity Name="Customer" Namespace="example.com" Version="">
             <Identifier Name="CustomerIdentifier" TypeName="System.Int32" />
             <Method Name="GetCustomer">
                 <!-- sp_GetCustomer is the name of the stored procedure that implements this method. -->
                 <Property Name="RdbCommandText" Type="System.String">sp_GetCustomer</Property>
                 <!-- Using stored procedures is a best practice when connecting to database systems. -->
               <Property Name="RdbCommandType" Type="System.Data.CommandType, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">StoredProcedure</Property>
                 <!-- The parameter name @CustomerId as expected by the stored procedure. -->
                 <Parameter Name="@CustomerId" Direction="In">
                   <!-- The IdentifierName attribute is required here. -->
                   <TypeDescriptor Name="Id" TypeName="System.Int32" IdentifierName="CustomerIdentifier" />
                 <Parameter Name="Customers" Direction="Return">
                 <!-- This SQL command returns a result set containing precisely one row, but it is still wrapped by a data reader and appears as a collection. -->
                   <TypeDescriptor Name="CustomerDataReader" TypeName="System.Data.SqlClient.SqlDataReader, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true">
                       <!-- This is a data record corresponding to a single row of the result set. -->
                       <TypeDescriptor Name="Customer" TypeName="System.Data.IDataRecord, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                           <!-- The IdentifierName attribute is required here to associate the field with the Identifier. -->
                           <TypeDescriptor Name="Id" TypeName="System.Int32" IdentifierName="CustomerIdentifier" />
                           <TypeDescriptor Name="FirstName" TypeName="System.String" />
                           <TypeDescriptor Name="LastName" TypeName="System.String" />
                 <!-- The ReturnParameterName and ReturnTypeDescriptor are pointing to the data record to be returned. The result set that is wrapping it is not important and can be ignored when processing results. -->
                 <MethodInstance Name="GetCustomer" Type="SpecificFinder" ReturnParameterName="Customers" ReturnTypeDescriptorName="Customer" />