In NH 3.x you can make the Blob property lazy.

Here's the HQL that will get you just the fields you want:

select a.AttachmentId, a.FileName from MyTable t join t.Attachments a
where t = :myTable


    Diego


On Tue, Jul 20, 2010 at 18:53, thecodefool <[email protected]> wrote:

> Hi All,
>
> This one has had me stumped for a while:
>
> I have three tables in the database
> 1. MyTable
> - MyTableId
> - Name
> 2. MyTable_Attachment
>  - MyTableId
> -  AttachmentId
> 3. Attachments
> - AttachmentId
> - FileName
> - Blob
>
>
> I have two classes
> MyTable
>  Id
> . Name
> ...
>
>
> Attachment
>  Id
>  FileName
>  Blob
> ...
>
>
> I have a mapping for MyTable
> mapping.HasManyToMany(x => x.Attachments)
>                .Table("MyTable_Attachment")
>                .ParentKeyColumn("MyTableId")
>                .ChildKeyColumn("AttachmentId")
>
> I can get a MyTable object and loop through the Attachments, however a
> blob field is undesirable as it could be large.
>
> I cannot remove the blob field( that I need to remove) to display a
> list of attachments -File Names and Id's for MyTable.
>
> I am trying to do something like this:
>
> SELECT a.AttachmentId, a.FileName
>     FROM Attachment AS a INNER JOIN MyTable_Attachment AS ma
>       ON a.AttachmentId = ma.AttachmentId
>  WHERE (ma.MyTableId =10)
>
> Maybe it is something that I have just been trying to hard at but any
> suggestion would be greatly appreciated!.
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to