New Posts New Posts RSS Feed: The problem is that we need to be able to decide of the SourceOwnerName at runtime
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

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

 Post Reply Post Reply
Author
Customer View Drop Down
Senior Member
Senior Member
Avatar
User Submitted Questions to Support

Joined: 30-May-2007
Location: United States
Posts: 260
Post Options Post Options   Quote Customer Quote  Post ReplyReply Direct Link To This Post Topic: The problem is that we need to be able to decide of the SourceOwnerName at runtime
    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 ?

Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post 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();
      }
    }
 

  }
 
}


 

 



Edited by IdeaBlade - 13-Jul-2007 at 10:06am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down