How to use a string content as a variable name in a SSIS C# script -


hello , time , answers in advanced. let me give context first: i'm working in bank in metrics project. re-engineering etl processes , microstrategy dashboards of commerce sector, use lot of non data sources , have map info centralized sources in sql server 2008r2 servers. etl using ssis.

i have etl loans. inside data flow gather information need loans, 1 particular table got conditions needs tested classify loan. conditions table has form:

sk_condition_name: varchar sk_whatever: ... ... where_clause: varchar(900) 

in "where_clause" column have clause (duh!) test columns loan this:

loan_type = x , client_tipe = y , loan_rate = z 

before deeper in this, need example i'm giving loans, same goes products bank sell, insurance or investment funds... and conditions classify product can change in time. and 1 specific loan can classified in multiple ways at same time, each positive clasification writes row in specific table, that's why need asynchronous script component.

where was? right, loans.. in etl in loans data , where_clauses, in c# script component separate clause regular expressions, end 2 strings every check clause doing, using example above end 3 pair of strings ("loan_type", "x"), ("client_type","y") , ("loan_rate",z).

and problem comes

i can't find way in script use first string content name of row column, mean:

if row.(string1.content()) = string2 ... 

now limitations:

  • it's bank, don't new things, tools can use of ssis.
  • changes in model might out of discussion, out of discussion.
  • i need dynamic, no hardcoded conditions because of changing nature of conditions.
  • i've search lot solution found non works. last resource.

i hope have been decently clear in this, first post ever.

please please please me!

thank much!!

edit 1: clarify..

my end result generating new row inserted in 1 particular table each condition tested positive. information inserted , target table irrelevant problema in hands. loan type, client , rate examples of conditions test. problema can't use string content name row's column.

you can reflection. add "using system.reflection;" namespaces - can interate following code:

public override void input0_processinputrow(input0buffer row) {      string scolumn = "name";     string sfind = "john";      foreach (propertyinfo p in row.gettype().getproperties())     {          string sval;          if (p.name.tostring() == scolumn)         {              sval = p.getvalue(row, null).tostring();              if (sval != sfind)              {                 //do stuff             }          }       }  } 

in example have hard-coded string1 (the column check) name , string2 (the value check) john.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -