a join operation is independent of the sources. so joining a file to
db (or db to db) (or a webservice to whatever) is all the same. I
haven't found a need for the NestedLoopsJoinOperation. I used the
JoinOperation class instead. here is an example.
public class LeftJoinOperation : JoinOperation
{
protected override Row MergeRows(Row leftRow, Row rightRow)
{
var row = leftRow.Clone();
if (rightRow["RightColumn"] == null) return row;
row["this"] = rightRow["that"];
return row;
}
protected override void SetupJoinConditions()
{
LeftJoin.Left("LeftColumn").Right("RightColumn");
}
}
and it would be used like this
Register(new LeftJoinOperation()
.Left(new Source1())
.Right(new Source2()))
.Register(new Destination());
in your scenario if rightRow["MODEL_NO"] is null then row["ITEM_NUM"]
will be null after the join. Since you are joining on this column
anyway, there isn't any value setting ITEM_NUM to MODEL_NO. I would
imagine you would want to copy other properties though.
On Apr 2, 11:28 am, Larry R <[email protected]> wrote:
> First time with RhinoETL, but I've looked at all the Unit Tests and
> the video. We really could use an example that does a input file
> joined with a lookup table on a DB. I think this has to be a really
> common situation.
>
> That is my case at least :D
>
> Left = Customer, Right = product lookup, Looking to do this in sql
> syntax
> Select c.*,mm.Product_ID from
> Customer c
> Left outer join ModelMaster mm on c.Item_No = mm.Model_No
>
> Here's what I have
> PortfolioRecord - has all the fields, plus some [FieldIgnored],
> including ProductId
> PortfolioRecord - same as above, but no ignored fields
> PortfolioReadOperation:AbstractOperation - works
> ModelMasterReadOperation:InputCommandOperation- seems to work
>
> Then here is the JoinModelMasterOperation:NestedLoopsJoinOperation
>
> public class JoinModelMasterOperation : NestedLoopsJoinOperation
> {
>
> protected override Row MergeRows(Row leftRow, Row rightRow)
> {
> Row row = leftRow.Clone();
> row["ITEM_NUM"] = rightRow["MODEL_NO"];
> return row;
> }
> protected override bool MatchJoinCondition(Row leftRow, Row
> rightRow)
> {
> return Equals(leftRow["ITEM_NUM"], rightRow["MODEL_NO"])
> || rightRow["MODEL_NO"] == null;
> }
> }
>
> Then for the execution,
>
> Register ( new JoinModelMasterOperation()
> .Left( new
> PortfolioReadOperation(inputFile) )
> .Right( new
> ModelMasterReadOperation("AftermarketDb") )
> );
> Register(new
> PortfolioWriteToFileOperation(Path.Combine(Settings.Default.OutputFilePath,
> "TestOutput.txt")));
>
> I expect about an 80% match, but I never get the ModelMaster.ProductId
> in the output. Any idea what I am missing here?
>
> Thanks for your time.
> Larry
--
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en.