Set Connection At Runtime

7 posts, 0 answers
  1. Garry
    Garry avatar
    205 posts
    Member since:
    Nov 2010

    Posted 11 May 2010 Link to this post

    I have an application that is based on Prism and MVVM. I have a shell, which of course loads multiple modules. Some modules use OpenAccess for their data needs. To make things a little more complex the application is also consider an occasionnaly connected app. It basically uses a local database cache (SQL CE) as it's data store when it is not directly connected to the SQL 2008 server. We will also have to support Oracle.

    I am basing my OpenAccess persistent classes off of the SQL CE database just because it's always available. Everything works great until runtime where I am wanting to do something like this in the OpenAccess ObjectScopeProvider.

    /// <summary>  
            /// Returns the instance of Database for the connectionId   
            /// specified in the Enable Project Wizard.  
            /// </summary>  
            /// <returns>Instance of Database.</returns>  
            /// <remarks></remarks>  
            static public Database Database()  
            {  
                bool connectionOnline = false;  
                  
     
                if (theObjectScopeProvider1 == null)  
                    theObjectScopeProvider1 = new InfrastructureScopeProvider();  
     
                if (theObjectScopeProvider1.myDatabase == null)  
                    //if the connection to the database is online then usethe live server otherwise redirect to the local client db  
                    if (connectionOnline)  
                    {  
                        theObjectScopeProvider1.myDatabase = Telerik.OpenAccess.Database.Get(Infrastructure.Properties.Settings.Default.ServerEliteLiveConnectionString);  
                    }  
                    else 
                    {  
                        theObjectScopeProvider1.myDatabase = Telerik.OpenAccess.Database.Get(Infrastructure.Properties.Settings.Default.ClientEliteLiveConnectionString);   
                    }  
     
                return theObjectScopeProvider1.myDatabase;  
            } 

    This of course is not working for me. I have looked at using the AdjustForDynamicLoad and the article on "How to: Dynamically Manage a Connection to a Data Store" and neither seem to fit this scenario. Which method should I use keeping in mind the backend store could be SQL CE, SQL 2005+, or Oracle for now.

    Also it appears that OpenAccess is looking in the Shells App.Config for the OpenAccess configuration section rather than the Modules App.Config. Should this be expected?

    Any help in solving this mysterty would be greatly appreciated.

    Thanks!
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 14 May 2010 Link to this post

    Hello Garry Clark,

    Since we have moved our conversation to the private channel, I would like to give some guidance here as well for other customers that may face similar difficulties.

    The problem with the Shell/Module config files is that OpenAccess starts looking for its configuration from the assembly that is currently running. And if it does not find it there (in the Shell's config), an exception is thrown. To avoid this and let OpenAccess find its real config file in the referenced assemblies (like Module) it is required that the following configuration is present in the App.config file of the executing assembly:
    ...
    <configSections>
        ...
        <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler, Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" requirePermission="false" />
    </configSections>
    ...
    ...
    <configuration>
      ...
      <openaccess xmlns="http://www.telerik.com/OpenAccess">
        <references>
          <reference assemblyname="Module" configrequired="True" />
        </references>
      </openaccess>
    </configuration>

    However, if it is not appropriate to keep that information in the configuration file, you can use the AdjustForDynamicLoad() method of the object scope provider class to provide the same configuration at runtime. The AdjustForDynamicLoad() method should be called before obtaining an object scope and this would ensure that the configuration from the referenced assemblies is loaded. This method could be additionally extended to provide richer information like connections or mapping details. The format is the same as in the App.config file, just append the necessary information to the assumedInitialConfiguration string in the method.

    Kind regards,
    Alexander
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Garry
    Garry avatar
    205 posts
    Member since:
    Nov 2010

    Posted 14 May 2010 Link to this post

    Worked wonderfully in my Prism application Alexander. Thank you very much!

    For anyone interested here is the two sections that I changed in my ObjectScopeProvider.

    /// <summary>  
            /// Adjusts for dynamic loading when no entry assembly is available/configurable.  
            /// </summary>  
            /// <remarks>  
            /// When dynamic loading is used, the configuration path from the  
            /// applications entry assembly to the connection setting might be broken.  
            /// This method makes up the necessary configuration entries.  
            /// </remarks>  
            static public void AdjustForDynamicLoad()  
            {  
                //ConnectionID  
                string connectionid = "EliteExtenderSecurity";  
                bool connectionOnline = false;  
                  
               if( theObjectScopeProvider1 == null )  
                    theObjectScopeProvider1 = new SecurityScopeProvider();  
     
                if( theObjectScopeProvider1.myDatabase == null )  
                {  
                    string assumedInitialConfiguration =  
                               "<openaccess>" +  
                                   "<references>" +  
                                       "<reference assemblyname='PLACEHOLDER' configrequired='True'/>" +  
                                   "</references>";  
                    //if the connection to the database is online then usethe live server otherwise redirect to the local client db  
                    if (connectionOnline == false)  
                    {  
                        assumedInitialConfiguration +=  
                                   "<connections>" +  
                                       "<connection id='" + connectionid + "'>" +  
                                           "<connectionString>" + Infrastructure.Properties.Settings.Default.ClientEliteLiveConnectionString + "</connectionString>" +  
                                            "<backendconfigurationname>sqlceConfiguration</backendconfigurationname>" +  
                                       "</connection>" +  
                                   "</connections>" +  
                                   "</openaccess>";  
                    }  
                    else 
                    {  
                        assumedInitialConfiguration +=  
                                   "<connections>" +  
                                       "<connection id='" + connectionid + "'>" +  
                                           "<connectionString>" + Infrastructure.Properties.Settings.Default.ServerEliteLiveConnectionString + "</connectionString>" +  
                                            "<backendconfigurationname>mssqlConfiguration</backendconfigurationname>" +  
                                       "</connection>" +  
                                   "</connections>" +  
                                   "</openaccess>";  
                    }  
                      
                    System.Reflection.Assembly dll = theObjectScopeProvider1.GetType().Assembly;  
                    assumedInitialConfiguration = assumedInitialConfiguration.Replace(  
                                                        "PLACEHOLDER", dll.GetName().Name);  
                    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();  
                    xmlDoc.LoadXml(assumedInitialConfiguration);  
                    Database db = Telerik.OpenAccess.Database.Get(connectionid,   
                                                xmlDoc.DocumentElement,  
                                                new System.Reflection.Assembly[] { dll } );  
     
                    theObjectScopeProvider1.myDatabase = db;  
                }  
            }  
     
            /// <summary>  
            /// Returns the instance of Database for the connectionId   
            /// specified in the Enable Project Wizard.  
            /// </summary>  
            /// <returns>Instance of Database.</returns>  
            /// <remarks></remarks>  
            static public Database Database()  
            {  
                if( theObjectScopeProvider1 == null )  
                    theObjectScopeProvider1 = new SecurityScopeProvider();  
     
                if( theObjectScopeProvider1.myDatabase == null )  
                    AdjustForDynamicLoad();  
                  
                return theObjectScopeProvider1.myDatabase;  
            } 
  5. Garry
    Garry avatar
    205 posts
    Member since:
    Nov 2010

    Posted 09 Jun 2010 Link to this post

    Alexander,
    I have now had some time to play with the code above and I have a few more issues I was hoping you could shed some light on. The basic issue is this. I have a local SQL CE 3.5 DB and a SQL 2008 DB. Basically my app is using Synchronization framework to create an offline version of the SQL 2008 DB thus the SQL CE DB.

    When my application launches it checks to see if the SQL 2008 DB is online, if so use it, if not use the local copy. All taht works fine, however OpenAccess seems to be having some issues making the transistion between the two DBs.

    Here is the code and the app.config responsible for making this happen.

     static public void AdjustForDynamicLoad()  
            {  
                //ConnectionID  
                string connectionid = "EliteExtenderInfrastructure";  
                bool connectionOnline = false;  
     
                if (theObjectScopeProvider1 == null)  
                    theObjectScopeProvider1 = new InfrastructureScopeProvider();  
     
                if (theObjectScopeProvider1.myDatabase == null)  
                {  
                    string assumedInitialConfiguration =  
                               "<openaccess>" +  
                                   "<references>" +  
                                       "<reference assemblyname='PLACEHOLDER' configrequired='True'/>" +  
                                   "</references>";  
                    //if the connection to the database is online then usethe live server otherwise redirect to the local client db  
                    if (EliteDataService.DatabaseOnline == false)  
                    {  
                        assumedInitialConfiguration +=  
                                   "<connections>" +  
                                       "<connection id='" + connectionid + "'>" +  
                                           "<connectionString>" + Infrastructure.Properties.Settings.Default.ClientEliteLiveConnectionString + "</connectionString>" +  
                                            "<backendconfigurationname>sqlceConfiguration</backendconfigurationname>" +  
                                       "</connection>" +  
                                   "</connections>" +  
                                   "</openaccess>";  
                    }  
                    else 
                    {  
                        assumedInitialConfiguration +=  
                                   "<connections>" +  
                                       "<connection id='" + connectionid + "'>" +  
                                           "<connectionString>" + Infrastructure.Properties.Settings.Default.ServerEliteLiveConnectionString + "</connectionString>" +  
                                            "<backendconfigurationname>mssqlConfiguration</backendconfigurationname>" +  
                                       "</connection>" +  
                                   "</connections>" +  
                                   "</openaccess>";  
                    }  
     
                    System.Reflection.Assembly dll = theObjectScopeProvider1.GetType().Assembly;  
                    assumedInitialConfiguration = assumedInitialConfiguration.Replace(  
                                                        "PLACEHOLDER", dll.GetName().Name);  
                    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();  
                    xmlDoc.LoadXml(assumedInitialConfiguration);  
                    Database db = Telerik.OpenAccess.Database.Get(connectionid,  
                                                xmlDoc.DocumentElement,  
                                                new System.Reflection.Assembly[] { dll });  
     
                    theObjectScopeProvider1.myDatabase = db;  
                }  
            } 

    App.config (I had to add two backend configuration sections) Do I need two mappings as well?
    <openaccess xmlns="http://www.telerik.com/OpenAccess">  
        <references /> 
        <connections> 
          <connection id="EliteExtender">  
            <backendconfigurationname>mssqlConfiguration</backendconfigurationname> 
            <databasename>EliteLive</databasename> 
            <servername>(local)</servername> 
            <integratedSecurity>False</integratedSecurity> 
            <user>sa</user> 
            <password>*********</password> 
          </connection> 
        </connections> 
        <backendconfigurations> 
          <backendconfiguration id="mssqlConfiguration" backend="mssql">  
            <mappingname>mssqlMapping</mappingname> 
          </backendconfiguration> 
          <backendconfiguration id="sqlceConfiguration" backend="sqlce">  
            <mappingname>mssqlMapping</mappingname> 
          </backendconfiguration> 
        </backendconfigurations> 
        <mappings current="mssqlMapping">  
          <mapping id="mssqlMapping">  
            <namespace name="EliteExtender.Infrastructure.Models">  
              <class name="EliteExtenderUser">  
                <extension key="db-table-name" value="eliteExtender_Users" /> 
                <field name="userId" behavior="insertonly">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="UserId" /> 
                  </extension> 
                </field> 
                <field name="applicationId">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="ApplicationId" /> 
                  </extension> 
                </field> 
                <field name="comment">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="Comment" /> 
                    <extension key="db-sql-type" value="NVARCHAR(MAX)" /> 
                    <extension key="db-length" value="4000" /> 
                  </extension> 
                </field> 
                <field name="creationDate">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="CreationDate" /> 
                  </extension> 
                </field> 
                <field name="email">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="Email" /> 
                  </extension> 
                </field> 
                <field name="failedPassAnsAttemptCount">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="FailedPassAnsAttemptCount" /> 
                  </extension> 
                </field> 
                <field name="failedPassAnsAttemptWndStart">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="FailedPassAnsAttemptCountWndStart" /> 
                  </extension> 
                </field> 
                <field name="failedPassAttemptCount">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="FailedPassAttemptCount" /> 
                  </extension> 
                </field> 
                <field name="failedPassAttemptWndStart">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="FailedPassAttemptWndStart" /> 
                  </extension> 
                </field> 
                <field name="isAnonymous">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="IsAnonymous" /> 
                  </extension> 
                </field> 
                <field name="isApproved">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="IsApproved" /> 
                  </extension> 
                </field> 
                <field name="isLockedOut">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="IsLockedOut" /> 
                  </extension> 
                </field> 
                <field name="lastActivityDate">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="LastActivityDate" /> 
                  </extension> 
                </field> 
                <field name="lastLockoutDate">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="LastLockoutDate" /> 
                  </extension> 
                </field> 
                <field name="lastLoginDate">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="LastLoginDate" /> 
                  </extension> 
                </field> 
                <field name="lastPasswordChangedDate">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="LastPasswordChangedDate" /> 
                  </extension> 
                </field> 
                <field name="loweredEmail">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="LoweredEmail" /> 
                  </extension> 
                </field> 
                <field name="loweredUserName">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="LoweredUserName" /> 
                  </extension> 
                </field> 
                <field name="mobileAlias">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="MobileAlias" /> 
                  </extension> 
                </field> 
                <field name="mobilePIN">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="MobilePIN" /> 
                  </extension> 
                </field> 
                <field name="password">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="Password" /> 
                  </extension> 
                </field> 
                <field name="passwordAnswer">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="PasswordAnswer" /> 
                  </extension> 
                </field> 
                <field name="passwordFormat">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="PasswordFormat" /> 
                  </extension> 
                </field> 
                <field name="passwordQuestion">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="PasswordQuestion" /> 
                  </extension> 
                </field> 
                <field name="passwordSalt">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="PasswordSalt" /> 
                  </extension> 
                </field> 
                <field name="userName">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="UserName" /> 
                  </extension> 
                </field> 
                <field name="m_error">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="ErrorMessage" /> 
                  </extension> 
                </field> 
                <extension key="db-key-generator" value="GUID" /> 
              </class> 
              <class name="EliteExtenderRole">  
                <extension key="db-table-name" value="eliteExtender_Roles" /> 
                <extension key="db-key-generator" value="GUID" /> 
                <field name="roleId">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="RoleId" /> 
                  </extension> 
                </field> 
                <field name="applicationId">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="ApplicationId" /> 
                  </extension> 
                </field> 
                <field name="description">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="Description" /> 
                  </extension> 
                </field> 
                <field name="loweredRoleName">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="LoweredRoleName" /> 
                  </extension> 
                </field> 
                <field name="roleName">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="RoleName" /> 
                  </extension> 
                </field> 
              </class> 
              <class name="EliteExtenderUsersInRole">  
                <extension key="db-table-name" value="eliteExtender_UsersInRoles" /> 
                <field name="roleId">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="RoleId" /> 
                  </extension> 
                </field> 
                <field name="userId">  
                  <extension key="db-column">  
                    <extension key="db-column-name" value="UserId" /> 
                  </extension> 
                </field> 
              </class> 
            </namespace> 
          </mapping> 
        </mappings> 
      </openaccess> 

    The issue I have when I switch between CE and SQL is that is says I have invalid columns and throws this error.
    Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'assisted_under_housing_act'.  
    Invalid column name 'entry_rsdnt_rsponsible_for_uti'.  
    Invalid column name 'f_s_s_participant'.  
    Invalid column name 'h_u_d_income_target_disregard'.  
    Invalid column name 'h_u_d_project_i_d'.  
    Invalid column name 'head_or_spouse_is_disabled'.  
    Invalid column name 'homeless_at_admission'.  
    Invalid column name 'is_excluded'.  
    Invalid column name 'is_m_t_w_sng_flt_mdcl_llowance'.  
    Invalid column name 'is_m_t_w_sng_stndard_rent_calc'.  
    Invalid column name 'is_mnimum_rent_amount_override'.  
    Invalid column name 'is_off_year_certification'.  
    Invalid column name 'is_rent_increase_only'.  
    Invalid column name 'previous_housing_type'.  
    Invalid column name 'r_s_s_qlified_for_hardship_adj'.  
    Invalid column name 'unit_state'.  
    Statement(s) could not be prepared.  
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()  
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()  
       at OpenAccessRuntime.Relational.fetch.FetchResultImp.execute()  
    SQL:  
    SELECT [ActionType], [AllowableDisabilityExpense], [AllowancePerDependant], [AssetPassbookRate], [assisted_under_housing_act], [CancelledDate], [CancelledReason], [CertificationCompleteDate], [CurrentBaseRent], [DateOfLastAnnualInspection], [DateUnitLastPassedInspection], [EarnedIncomeDeduction], [EarningsDueToDisabilityExp], [EffectiveDate], [ElderlyDisabilityAllowance], [ElderlyDisabilityAllowanceType], [EntryAnnualHeatAllowance], [EntryAnnualHeatRoomsAllowance], [EntryChildCareAllowance], [EntryDayCareAllowance], [EntryHomemakingExpAllowance], [entry_rsdnt_rsponsible_for_uti], [EntrySupportPaymentsAllowance], [EntryTravelAllowance], [f_s_s_participant], [FinalAssetIncome], [fkMLSosCodeActionType], [fkMlsosCodeSubsidyType], [fkosAddressDetail], [fkosCompanyWorkerCancelled], [fkosCompanyWorkerCompleted], [fkosCompanyWorkerMTCSCancelled], [fkosCompanyWorkerMinimumRentOv], [fkosParticipant], [fkptApprovedCertificationVoidedBy], [fkptApprovedCertificationVoiding], [FlatMedicalAllowance], [FormerHeadSocialSecurityNumber], [h_u_d_income_target_disregard], [h_u_d_project_i_d], [head_or_spouse_is_disabled], [homeless_at_admission], [ImputedAssetIncome], [IneligibleFamilyMemberFee], [is_excluded], [is_m_t_w_sng_flt_mdcl_llowance], [is_m_t_w_sng_stndard_rent_calc], [is_mnimum_rent_amount_override], [is_off_year_certification], [is_rent_increase_only], [LastModifiedDate], [lkpmUnit], [fkMLSosCodeActionType], [fkMlsosCodeSubsidyType], [MRVPFinalLHAShare], [MRVPFinalTenantShare], [MRVPLHAShare], [MRVPMonthlyNetIncome], [MRVPMonthlyNetIncome40Percent], [MRVPPotTenShareVoucherValues], [MRVPPotentialVoucherValue], [MRVPTenantShare30Percent], [MRVPUnitContractRent], [MRVPVoucherAmountFromSchedule], [MRVPVoucherBedrooms], [MTCSWorkerCancelledDate], [MaximumDisabilityAllowance], [MedicalThresholdAmount], [MedicalThresholdPercent], [MinimumRentAmount], [MinimumRentAmountOverrideDate], [MostRecentTTP], [NumberOfBedroomsInUnit], [NumberOfDependants], [fkosParticipant], [OwnerName], [OwnerSSN], [ParamElderlyDisableAllowance], [PercentOfGrossFactor], [PercentOfNetFactor], [previous_housing_type], [RSAllowableChildcareDeductions], [RSAllowableMedicalDeductions], [RSChildcareExpenses], [r_s_s_qlified_for_hardship_adj], [RSMedicalExpenses], [RSNote], [RentCAnnualHeatAllowance], [RentCAnnualHeatRoomsAllowance], [RentCChildCareAllowance], [RentCDayCareAllowance], [RentCHomemakingExpAllowance], [RentCStudentUnder25IncomeExc], [RentCSupportPaymentsAllowance], [RentCTravelAllowance], [RentCWorkingChildIncomeExc], [SubsidyTypeEffectiveDate], [TTPAmount], [TTPIfBasedOnAdjAnnualIncome], [TTPIfBasedOnGrossAnnualIncome], [TotalAdjustedAnnualIncome], [TotalAdjustedMonthlyIncome], [TotalAllowableDisabilityAndMed], [TotalAnticipatedAssetIncome], [TotalCashValueOfAssets], [TotalCombinedAllowances], [TotalDependantAllowance], [TotalDisabilityAssistAndMedExp], [TotalGrossAnnualIncome], [TotalGrossMonthlyIncome], [TotalIncomeAfterExclusions], [TotalIncomeExclusions], [TotalOutOfPocketMedicalExpense], [TotalUnreimbursedChildcareExp], [TotalUnreimbursedDisabilityExp], [TravelCostToWorkOrSchool], [UnitCity], [UnitPrimaryStreet], [UnitSecondaryStreet], [unit_state], [UnitSuite], [UnitZip], [YearUnitBuilt] FROM [ptApprovedCertification] WHERE [PK] = ?          Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'assisted_under_housing_act'.  
    Invalid column name 'entry_rsdnt_rsponsible_for_uti'.  
    Invalid column name 'f_s_s_participant'.  
    Invalid column name 'h_u_d_income_target_disregard'.  
    Invalid column name 'h_u_d_project_i_d'.  
    Invalid column name 'head_or_spouse_is_disabled'.  
    Invalid column name 'homeless_at_admission'.  
    Invalid column name 'is_excluded'.  
    Invalid column name 'is_m_t_w_sng_flt_mdcl_llowance'.  
    Invalid column name 'is_m_t_w_sng_stndard_rent_calc'.  
    Invalid column name 'is_mnimum_rent_amount_override'.  
    Invalid column name 'is_off_year_certification'.  
    Invalid column name 'is_rent_increase_only'.  
    Invalid column name 'previous_housing_type'.  
    Invalid column name 'r_s_s_qlified_for_hardship_adj'.  
    Invalid column name 'unit_state'.  
    Statement(s) could not be prepared.  
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()  
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()  
       at OpenAccessRuntime.Relational.fetch.FetchResultImp.execute() 

    Do I need to have different mappings for different DBs? I mean its the same schema as far as tables are concerned.

    Any help would be appreciated.

    Thanks!
  6. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 10 Jun 2010 Link to this post

    Hi Garry Clark,

    I believe you will not need two mappings. However, the mapping you posted seems incomplete. I see there only three classes (EliteExtenderUser, EliteExtenderRole, EliteExtenderUsersInRole) that were probably reverse mapped some time ago. From the exception I assume that you have other classes (ptApprovedCertification) but the mapping does not contain information about them. In this case default mapping is used and the table/column names could differ from the ones that you may actually have in the database.
    So what I would recommend you to do is to reverse map again the full database (or do a Merge to add just the new tables). This way you will get longer mapping configuration that contains the information for all tables found in the database. Then OpenAccess will know how to find the tables/columns mapped to a class and the query should succeed.

    All the best,
    Alexander
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Garry
    Garry avatar
    205 posts
    Member since:
    Nov 2010

    Posted 10 Jun 2010 Link to this post

    Alexander,
    The mappings I posted earlier are from another module. No clue why I did that, but below are the correct mappings. As you can see those fields do exist, but not the way OpenAccess is interpreting them.
    <class name="PtApprovedCertification"
                <field name="pk" null-value="exception"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="PK" /> 
                  </extension> 
                </field> 
                <field name="actionType"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="ActionType" /> 
                    <extension key="db-length" value="50" /> 
                  </extension> 
                </field> 
                <field name="allowableDisabilityExpense"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="AllowableDisabilityExpense" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="allowancePerDependant"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="AllowancePerDependant" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="assetPassbookRate"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="AssetPassbookRate" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="assistedUnderHousingAct"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="AssistedUnderHousingAct" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="cancelledDate"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="CancelledDate" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="cancelledReason"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="CancelledReason" /> 
                    <extension key="db-length" value="255" /> 
                  </extension> 
                </field> 
                <field name="certificationCompleteDate"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="CertificationCompleteDate" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="currentBaseRent"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="CurrentBaseRent" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="dateOfLastAnnualInspection"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="DateOfLastAnnualInspection" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="dateUnitLastPassedInspection"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="DateUnitLastPassedInspection" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="earnedIncomeDeduction"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EarnedIncomeDeduction" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="earningsDueToDisabilityExp"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EarningsDueToDisabilityExp" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="effectiveDate"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="EffectiveDate" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="elderlyDisabilityAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="ElderlyDisabilityAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="elderlyDisabilityAllowanceType"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="ElderlyDisabilityAllowanceType" /> 
                    <extension key="db-length" value="50" /> 
                  </extension> 
                </field> 
                <field name="entryAnnualHeatAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EntryAnnualHeatAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="entryAnnualHeatRoomsAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EntryAnnualHeatRoomsAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="entryChildCareAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EntryChildCareAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="entryDayCareAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EntryDayCareAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="entryHomemakingExpAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EntryHomemakingExpAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="entryResidentResponsibleForUti"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="EntryResidentResponsibleForUti" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="entrySupportPaymentsAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EntrySupportPaymentsAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="entryTravelAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="EntryTravelAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="fSSParticipant"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="FSSParticipant" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="finalAssetIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="FinalAssetIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="fkMLSosCodeActionType"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkMLSosCodeActionType" /> 
                  </extension> 
                </field> 
                <field name="fkMlsosCodeSubsidyType"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkMlsosCodeSubsidyType" /> 
                  </extension> 
                </field> 
                <field name="fkosAddressDetail"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkosAddressDetail" /> 
                  </extension> 
                </field> 
                <field name="fkosCompanyWorkerCancelled"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkosCompanyWorkerCancelled" /> 
                  </extension> 
                </field> 
                <field name="fkosCompanyWorkerCompleted"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkosCompanyWorkerCompleted" /> 
                  </extension> 
                </field> 
                <field name="fkosCompanyWorkerMTCSCancelled"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkosCompanyWorkerMTCSCancelled" /> 
                  </extension> 
                </field> 
                <field name="fkosCompanyWorkerMinimumRentOv"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkosCompanyWorkerMinimumRentOv" /> 
                  </extension> 
                </field> 
                <field name="fkosParticipant" null-value="exception"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkosParticipant" /> 
                  </extension> 
                </field> 
                <field name="formerHeadSocialSecurityNumber"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="FormerHeadSocialSecurityNumber" /> 
                    <extension key="db-length" value="11" /> 
                  </extension> 
                </field> 
                <field name="hUDIncomeTargetDisregard"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="HUDIncomeTargetDisregard" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="hUDProjectID"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="HUDProjectID" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="15" /> 
                  </extension> 
                </field> 
                <field name="headOrSpouseIsDisabled"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="HeadOrSpouseIsDisabled" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="homelessAtAdmission"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="HomelessAtAdmission" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="imputedAssetIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="ImputedAssetIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="isExcluded"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="IsExcluded" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="isMinimumRentAmountOverride"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="IsMinimumRentAmountOverride" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="isRentIncreaseOnly"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="IsRentIncreaseOnly" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="lastModifiedDate"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="LastModifiedDate" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="lkpmUnit"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="lkpmUnit" /> 
                  </extension> 
                </field> 
                <field name="mRVPFinalLHAShare"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPFinalLHAShare" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPFinalTenantShare"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPFinalTenantShare" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPLHAShare"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPLHAShare" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPMonthlyNetIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPMonthlyNetIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPMonthlyNetIncome40Percent"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPMonthlyNetIncome40Percent" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPPotTenShareVoucherValues"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPPotTenShareVoucherValues" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPPotentialVoucherValue"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPPotentialVoucherValue" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPTenantShare30Percent"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPTenantShare30Percent" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPUnitContractRent"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPUnitContractRent" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPVoucherAmountFromSchedule"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MRVPVoucherAmountFromSchedule" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="mRVPVoucherBedrooms"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="MRVPVoucherBedrooms" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="mTCSWorkerCancelledDate"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="MTCSWorkerCancelledDate" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="maximumDisabilityAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MaximumDisabilityAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="medicalThresholdAmount"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MedicalThresholdAmount" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="medicalThresholdPercent"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MedicalThresholdPercent" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="minimumRentAmount"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MinimumRentAmount" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="minimumRentAmountOverrideDate"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="MinimumRentAmountOverrideDate" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="mostRecentTTP"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="MostRecentTTP" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="numberOfBedroomsInUnit"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="NumberOfBedroomsInUnit" /> 
                  </extension> 
                </field> 
                <field name="numberOfDependants"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="NumberOfDependants" /> 
                  </extension> 
                </field> 
                <field name="ownerName"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="OwnerName" /> 
                    <extension key="db-length" value="50" /> 
                  </extension> 
                </field> 
                <field name="ownerSSN"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="OwnerSSN" /> 
                    <extension key="db-length" value="9" /> 
                  </extension> 
                </field> 
                <field name="paramElderlyDisableAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="ParamElderlyDisableAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="percentOfGrossFactor"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="PercentOfGrossFactor" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="percentOfNetFactor"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="PercentOfNetFactor" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="previousHousingType"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="PreviousHousingType" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="1" /> 
                  </extension> 
                </field> 
                <field name="rentCAnnualHeatAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCAnnualHeatAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rentCAnnualHeatRoomsAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCAnnualHeatRoomsAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rentCChildCareAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCChildCareAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rentCDayCareAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCDayCareAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rentCHomemakingExpAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCHomemakingExpAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rentCStudentUnder25IncomeExc"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCStudentUnder25IncomeExc" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rentCSupportPaymentsAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCSupportPaymentsAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rentCTravelAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCTravelAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rentCWorkingChildIncomeExc"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RentCWorkingChildIncomeExc" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="subsidyTypeEffectiveDate"
                  <extension key="db-column"
                    <extension key="db-type" value="TIMESTAMP" /> 
                    <extension key="db-column-name" value="SubsidyTypeEffectiveDate" /> 
                    <extension key="db-scale" value="3" /> 
                  </extension> 
                </field> 
                <field name="tTPAmount"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TTPAmount" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="tTPIfBasedOnAdjAnnualIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TTPIfBasedOnAdjAnnualIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="tTPIfBasedOnGrossAnnualIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TTPIfBasedOnGrossAnnualIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalAdjustedAnnualIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalAdjustedAnnualIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalAdjustedMonthlyIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalAdjustedMonthlyIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalAllowableDisabilityAndMed"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalAllowableDisabilityAndMed" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalAnticipatedAssetIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalAnticipatedAssetIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalCashValueOfAssets"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalCashValueOfAssets" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalCombinedAllowances"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalCombinedAllowances" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalDependantAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalDependantAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalDisabilityAssistAndMedExp"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalDisabilityAssistAndMedExp" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalGrossAnnualIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalGrossAnnualIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalGrossMonthlyIncome"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalGrossMonthlyIncome" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalIncomeAfterExclusions"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalIncomeAfterExclusions" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalIncomeExclusions"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalIncomeExclusions" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalOutOfPocketMedicalExpense"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalOutOfPocketMedicalExpense" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalUnreimbursedChildcareExp"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalUnreimbursedChildcareExp" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="totalUnreimbursedDisabilityExp"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TotalUnreimbursedDisabilityExp" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="travelCostToWorkOrSchool"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="TravelCostToWorkOrSchool" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="unitCity"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="UnitCity" /> 
                    <extension key="db-length" value="25" /> 
                  </extension> 
                </field> 
                <field name="unitPrimaryStreet"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="UnitPrimaryStreet" /> 
                    <extension key="db-length" value="50" /> 
                  </extension> 
                </field> 
                <field name="unitSecondaryStreet"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="UnitSecondaryStreet" /> 
                    <extension key="db-length" value="50" /> 
                  </extension> 
                </field> 
                <field name="unitState"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="UnitState" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="2" /> 
                  </extension> 
                </field> 
                <field name="unitSuite"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="UnitSuite" /> 
                    <extension key="db-length" value="10" /> 
                  </extension> 
                </field> 
                <field name="unitZip"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="UnitZip" /> 
                    <extension key="db-length" value="10" /> 
                  </extension> 
                </field> 
                <field name="yearUnitBuilt"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="YearUnitBuilt" /> 
                  </extension> 
                </field> 
                <field name="mLSosCodeActionType"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkMLSosCodeActionType" /> 
                  </extension> 
                </field> 
                <field name="mLSosCodeSubsidyType"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkMlsosCodeSubsidyType" /> 
                  </extension> 
                </field> 
                <field name="osParticipant" null-value="exception"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkosParticipant" /> 
                  </extension> 
                </field> 
                <field name="ptAMember"
                  <collection> 
                    <extension key="inverse" value="ptApprovedCertification" /> 
                  </collection> 
                </field> 
                <extension key="db-do-not-create-table" value="true" /> 
                <extension key="db-table-name" value="ptApprovedCertification" /> 
                <field name="fkptApprovedCertificationVoidedBy"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkptApprovedCertificationVoidedBy" /> 
                  </extension> 
                </field> 
                <field name="fkptApprovedCertificationVoiding"
                  <extension key="db-column"
                    <extension key="db-type" value="INTEGER" /> 
                    <extension key="db-column-name" value="fkptApprovedCertificationVoiding" /> 
                  </extension> 
                </field> 
                <field name="flatMedicalAllowance"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="FlatMedicalAllowance" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="ineligibleFamilyMemberFee"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="IneligibleFamilyMemberFee" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="isMTWUsingFlatMedicalAllowance"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="IsMTWUsingFlatMedicalAllowance" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="isMTWUsingStandardRentCalc"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="IsMTWUsingStandardRentCalc" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="isOffYearCertification" null-value="exception"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="IsOffYearCertification" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="rSAllowableChildcareDeductions"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RSAllowableChildcareDeductions" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rSAllowableMedicalDeductions"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RSAllowableMedicalDeductions" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rSChildcareExpenses"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RSChildcareExpenses" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rSIsQualifiedForHardshipAdj"
                  <extension key="db-column" value="sqlce"
                    <extension key="db-type" value="CHAR" /> 
                    <extension key="db-column-name" value="RSIsQualifiedForHardshipAdj" /> 
                    <extension key="db-sql-type" value="nchar" /> 
                    <extension key="db-length" value="3" /> 
                  </extension> 
                </field> 
                <field name="rSMedicalExpenses"
                  <extension key="db-column"
                    <extension key="db-type" value="NUMERIC" /> 
                    <extension key="db-column-name" value="RSMedicalExpenses" /> 
                    <extension key="db-length" value="19" /> 
                    <extension key="db-scale" value="4" /> 
                  </extension> 
                </field> 
                <field name="rSNote"
                  <extension key="db-column"
                    <extension key="db-type" value="VARCHAR" /> 
                    <extension key="db-column-name" value="RSNote" /> 
                    <extension key="db-length" value="255" /> 
                  </extension> 
                </field> 
                <extension key="db-optimistic-locking" value="changed" /> 
              </class> 

    To update this post though. I have now moved all my modules to use the new Open Access Domain Model, which may have been a mistake, because I am totally lost now. It appears that the scope provider which allowed me to change things at run time is no longer used and I can't find anything on the boards or in the documentation that talks about the new way of doing things.

    The help does make mention of the new Context stuff but the examples, such as the ones below, do not show how or where this context comes from. I mean in this example where did NorthwindDbContext come from? I have no Context object in my code.
    using ( NorthwindDbContext dbContext = new NorthwindDbContext() )  
    {  
       IQueryable<Customer> customersQuery = from customer in dbContext.Customers  
                                             where customer.Country == "Germany"  
                                             select customer;  
       Console.WriteLine( "Customer IDs: " );  
       foreach ( var item in customersQuery )  
       {  
           Console.WriteLine( item.CustomerID );  
       }  
    }  
    Also this help topic is titles "How to: Manage OpenAccessContext", but it only contains 2 non-existent articles. The online documentation seems to be further behind the .chm help as well. 
    Telerik OpenAccess ORM Programmers Guide Send comments on this topic.
    How to: Manage OpenAccessContext   
    See Also   
    OpenAccess ORM Visual Designer > Programming Guide > OpenAccess Tasks > Managing OpenAccessContext > How to: Manage OpenAccessContext   
    Glossary Item Box  
    This topic provides an example of how to manually open a connection for an OpenAccessContext. The example also shows how to ensure that the OpenAccessContext is released by calling Dispose on the context.  
      
    Once a new instance of OpenAccessContext has been created, a new connection to the database is also created. The connection is closed when the OpenAccessContext is disposed. The OpenAccessContext implements the IDisposable interface, thus it provides a Dispose() method and could be used inside a using statement.  
      
    See Also  
    How to: Trace SQL Statements Generated by OpenAccessContext  
    Anyhow long story short, to late I know, but can you explain how to do what we just did but using the new OpenAccess Domain Model and this phantom Context object please?

    I also had a similar post on this thread asking the same thing, but it has not been replied to yet, so it may be better if my latter question was answered there.

    Thanks!






  8. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 10 Jun 2010 Link to this post

    Hello Garry,

    Although the mapping is there It seems that it is not used. However, since you have moved to the new code generation I will not dig into that right now.
    In fact with the designer it should be easier to get those things working. The context class is automatically generated for each model (diagram) and replaces the old object scope. It is basically used the same way as the object scope. The most important differences that you should be aware of are that you do not have an Extent<> method but separate IQueryable endpoints for each class. Beginning a transaction is also not needed, just call SaveChanges() to persist the changes you have made.
    You will not need the AdjustForDynamicLoad() method either, no mapping information is written now in the config files except the connection strings. The context class has a constructor which accepts a connection string or a connection string name (the connection string itself should be available in the app.config). You can use this constructor to set which connection is to be used. The code would look like this:
    string connectionString = @"data source=.\sqlexpress;initial catalog=AdventureWorks;integrated security=True";
    BackendConfiguration backendConfig = new BackendConfiguration();
    backendConfig.Backend = "mssql"; //or "sqlce"
    MetadataSource source = XmlMetadataSource.FromAssemblyResource(persistentClassesAssembly, "AdventureWorksEntityDiagrams.rlinq");
     
    AdventureWorksEntityDiagrams context = new AdventureWorksEntityDiagrams(connectionString, backendConfig, source);
    where the persistentClassesAssembly is the assembly containing the classes managed by that context. You do not need to provide the assembly explicitly if the .rlinq file is present in the same assembly where this code is located.
    I think this would be enough for a start, please get back to us if you need more information. In the meantime I will check those empty documentation topics and make sure they are corrected.

    All the best,
    Alexander
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
DevCraft banner