开发者

Problem with different datatypes

I have a project that runs some code on SSIS in SqlServer 2005 and SqlServer 2008. My problem is that i maintain two Visual Studio solutions for this, because the data types for the two versions of the SQL Server are different (ends with ..90 on SQL Server 2005 and ...10 on SQL Server 2008). They are in different assemblies also.

Is there an easy way to manage this, both in development and in build, i hate having to enter my code in two places (each solution) and with SQL Server 2011 coming i suspect that i will have to do it three times. How do you solve this, or any advice on how to solve this in general?

Edit: Here is a sample of what I'm doing, as i see it its hard to factor this out in an interface, or?

foreach (IDTSVirtualInputColumn90 virtualColumn in virtualInput.VirtualInputColumnCollection)
{
    if (string.Compare(virtualColumn.Name, columnTransformation.FromColumn.Name, true) == 0 || (columnTransformation.FromColumn.Preformatted && columnTransformation.FromColumn.Name.EndsWith(" as \"" + virtualColumn.Name + "\"")))
    {
       convInstance.S开发者_Go百科etUsageType(input.ID, virtualInput, virtualColumn.LineageID, DTSUsageType.UT_READONLY);
       IDTSOutputColumn90 outputColumn = convComponent.OutputCollection[0].OutputColumnCollection.New();
       outputColumn.Name = virtualColumn.Name + " (Converted)";
       outputColumn.SetDataTypeProperties(columnTransformation.ToColumn.DataType, columnTransformation.ToColumn.Length, columnTransformation.ToColumn.Precision, columnTransformation.ToColumn.Scale, 0);
       outputColumn.ErrorRowDisposition = DTSRowDisposition.RD_FailComponent;
       outputColumn.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
       IDTSCustomProperty90 outputProp = outputColumn.CustomPropertyCollection.New();
       outputProp.Name = "SourceInputColumnLineageID";
       outputProp.Value = virtualColumn.LineageID;
       outputProp = outputColumn.CustomPropertyCollection.New();
       outputProp.Name = "FastParse";
       outputProp.Value = false;
       break;
     }
}


It's not really clear what your code is doing, but the normal approach to this sort of thing would be to create an interface or abstract class, and then have multiple implementations (or derived classes) for the specialized behaviour. All the common code can just talk to the abstraction, letting the implementation deal with the details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜