Print Page | Close Window

The problem is that we need to be able to decide of the SourceOwnerName at runtime

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=237
Printed Date: 13-Mar-2025 at 5:53am


Topic: The problem is that we need to be able to decide of the SourceOwnerName at runtime
Posted By: Customer
Subject: The problem is that we need to be able to decide of the SourceOwnerName at runtime
Date Posted: 12-Jul-2007 at 5:21pm

I’m currently evaluating your product for one of our projects. We will have to access existing data in Oracle databases, but these data could be created in diffrent users. My experience with IdeaBlade is that there is no way to specify the owner at runtime; the mapping information is provided at design time only.

Could-you help me find a way to work around this limitation ?




Replies:
Posted By: IdeaBlade
Date Posted: 12-Jul-2007 at 5:23pm
 
Dynamicaly changing the OWNER can be done using the DataMappingInterceptor.  Here is an example below.
 
using System;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using System.Security.Principal;
using System.Net;
 
#if DEBUG_VB
using IdeaBladeRdbTest.Entities1.VB;
#else
using IdeaBladeRdbTest.Entities1.CS;
#endif
 
using IdeaBlade.Rdb;
using IdeaBlade.Persistence;
using IdeaBlade.Persistence.Rdb; 
using IdeaBlade.Util;
 

namespace IdeaBladeRdbTest.Entities1 { 
 
 
  public class OracleMappingInterceptor : DataSourceMappingInterceptor {
 
    public override void UpdateSourceMapping(IDataSourceKey pKey, EntityTable pEntityTable) {
      RdbKey aRdbKey = pKey as RdbKey;
      if (aRdbKey == null || aRdbKey.DatabaseDriver.DatabaseProduct != DatabaseProduct.Oracle) {
        return;
      }
 
      RdbTableMappingInfo info = pEntityTable.TableMappingInfo as RdbTableMappingInfo;
      info.SchemaInitializationMode = SchemaInitializationMode.FromDataSource;
      info.SourceOwnerName = "SA";
      info.SourceTableName = info.SourceTableName.ToUpper();
      info.SourceColumnNames = info.SourceColumnNames.ToUpper();
      foreach (DataColumnMapping columnMapping in info.TableMapping.ColumnMappings) {
        columnMapping.SourceColumn = columnMapping.SourceColumn.ToUpper();
      }
      if (info.ColumnInsertMap.ContainsKey("RowVersion")) {
        info.ColumnInsertMap["RowVersion"] = info.ColumnInsertMap["RowVersion"].ToUpper();
      }
      if (info.ColumnUpdateMap.ContainsKey("RowVersion")) {
        info.ColumnUpdateMap["RowVersion"] = info.ColumnUpdateMap["RowVersion"].ToUpper();
      }
    }
 

  }
 
}


 

 




Print Page | Close Window