views:

14

answers:

1

I'm trying to do a join like this using fluent nhibernate:

Id(x => x.Id);
Map(x => x.SourceSystemRecordId,"sourceSystemRecord_id");

Then

Join("cat.tbl_SourceSystemRecords", SourceSystemRecords);

But, it seems I don't have a way to specify the column I want to join with from the first table, in this case I need to join on SourceSystemRecordId and not on Id

Is there any way I can specify this? I tried References() but that requires me to create an object for this relationship, what I need is to aggregate the columns in sourcesystem records to the ones in the main table.

+1  A: 

I tried References() but that requires me to create an object for this relationship

Did you tried Expand method for references?

EDIT: Expand method joining columns which is referenced. and if you dont want to use lazy loading, this is how can you fix.

ps. still i cant understand it clearly. If this is not what you want, please give more details / examples.

eg.

Database:

Examples:
-Id

SourceSystemRecords:
-Id
-ExampleId

Entity:

Example:
Id / int
SourceSystemRecords / SourceSystemRecords - Referenced

Query:

Session.Linq<Example>().Expand("SourceSystemRecords")
cem
What do you mean expand, I'm using nhibernate, can you clarify a little bit more please?
MexicanHacker
I edited. -or- I should ask, I think you just want get referenced properties in one query - not lazy loading. Am i right?
cem
this worked, thanks a lot man.
MexicanHacker
you're welcome.
cem