0

Consider the following relationship between Item and ItemContent.

Item
ItemId
ItemName

ItemContent
ContentId
ItemId
Content
ContentType

What I would like to do is have a Content property on Item that JOINS the Content column from ItemContent based on ContentType that is provided in the mapping itself or injected in some other way.

What is the best way to accomplish this? What is the simplest way to accomplish this?

1 Answer 1

1

Well - according to Ayend Rahien it is possible to use a filter directly in the mapping. I have not tried it - but normally it should work if the says it works.

<set name="Comments"
   table="Comments">
   <key column="PostId"/>
   <one-to-many class="Comment"/>
   <filter name="effectiveDate"
   condition=":asOfDate >= PostedAt"/>
</set>

Here is the whole article about NHibernate filters on his blog

Sign up to request clarification or add additional context in comments.

2 Comments

Any idea on how this would be done using mapping by code? I've tried using the Property mapping, but there is no option for filter in that. Only formula. Formula is generating completely bogus SQL for me at this time.
well - this solution would be directly in the mapping file. I don't know if your way of mapping support this. Another idea would be using this technique: stackoverflow.com/questions/1787074/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.