Posted Mon, 13 May 2019 13:26:47 GMT by

I have a framework which uses BIML meta definition files with <tables><table><column> definitions in and then some package emitting BIML that this structure gets fed into.

My problem is that I'm adding a HASHBYTES based checksum to the packages. Getting it to generate the script transform task code in the packages is kind of ok but I'm using some code (a sproc) in the dest DB to generate the HASHBYTES statement for my testing rig. The sproc in the DB orders the columns for the table alphabetically but I can't figure out how to do this in the loops I have in the Package emitting BIML.

The order seems to be the order of the cols as they are listed in the generated BIML meta data definition. I could try and fix that I suppose but it feels a bit like a crummy workaround cos I'm missing something obvious in the c# (my c# is best described as rudimentary)

I have tried duplicating the list and then ordering the duplicate then trying to use the original index to then access the original object but am obviously doing something major stupid as this is just spinning its wheels and the actual ordre of the emit doesn't seem to be any different.

Can anyone point me at anything I can read up that will point me in the right direction.

 

many thanks

 

Steve

 

Posted Mon, 13 May 2019 20:37:07 GMT by

You can either post your code here or send it to support@varigence.com and we will take a look.

Posted Wed, 15 May 2019 19:04:44 GMT by

Ha ha!

 

I found it

First you have to add some stuff

<#@ import namespace="System.Collections.Generic" #> 
<#@ import namespace="System.Reflection" #> 
<#@ import namespace="System" #> 
<#@ import namespace="System.Linq" #> 

THEN YOU CAN DO THIS

<#

var colList = new List<String>();
var OrderedColList = new List<String>();
var OrderedColObjList = new List<AstTableColumnBaseNode>();

foreach(var column in table.Columns ) {
colList.Add(column.Name);
}

OrderedColList = colList.OrderBy(x=>x).ToList();

foreach(var column in OrderedColList ) {
logger.Info("OrderedColList.Columns OUTPUT {0}",column);

foreach(var colObj in table.Columns){
if(colObj.Name == column){
OrderedColObjList.Add(colObj);
}
}

}

#>

Now I have an ordered list of the columns in the OrderedColObjList list which has all the tags, annotations and properties form the original columns

 

 

 

You must be signed in to post in this forum.