A short FYI here to anyone building custom SSIS components. If you need to find out whether the component's input is sorted or not you cannot check the IsSorted property of the input - it will always return false regardless of whether the input is sorted or not. Instead, you need to check the virtual input.
In other words, the following code inside the Validate() method will always return DTSValidationStatus.VS_ISBROKEN:
public override DTSValidationStatus Validate()
{
IDTSComponentMetaData90 metadata = this.ComponentMetaData;
if (!metadata.InputCollection[0].IsSorted)
{
PostError("Input must be sorted");
return DTSValidationStatus.VS_ISBROKEN;
}
else
{
return DTSValidationStatus.VS_ISVALID;
}
}
Whereas the following simple amendment will return DTSValidationStatus.VS_ISBROKEN or DTSValidationStatus.VS_ISVALID as appropriate:
public override DTSValidationStatus Validate()
{
IDTSComponentMetaData90 metadata = this.ComponentMetaData;
IDTSVirtualInput90 vinput = metadata.InputCollection[0].GetVirtualInput();
if (!vinput.IsSorted)
{
PostError("Input must be sorted");
return DTSValidationStatus.VS_ISBROKEN;
}
else
{
return DTSValidationStatus.VS_ISVALID;
}
}
The rationale for this is explained here by the architect of the dataflow, Matt David. To paraphrase Matt, the IsSorted property of the input is dependant on whether any columns are selected or not. This is not the case with the Virtual Input.
-Jamie