I have a class that looks like this:

public class Company
{
   // ....

   ICollection<string> Notes;

  // ....
}

The table for notes has 2 fields:

table notes
   id int,  -- company Id
   note nvarchar(50)

The mapping in fluent nhibernate looks like this:

            HasMany(e => e.Notes).Table("notes")
                          .KeyColumn("id")
                          .Cascade.All()
                          .LazyLoad()
                          .AsSet().Element("note");

Everything works great as far as the mapping goes. However, I cannot
figure out how to query by the note text using ICriteria.

Let's say I want to find all companies that have notes with text
"testing 123".

I tried doing a query as follows:

var query = session.CreateCriteria<Company>();
query.CreateAlias("Notes", "note").Add(Restrictions.Eq("note",
noteToFind /* a string object */));
var companeis = query.List();

It says note is not a property of object Company. I cannot do it with
an inner criteria on the Notes property as well.

Any help would be appreciated.


For nitpickers: I know this is not how you search for free text in
real life. This is just an example with non-actual entity types or
data.



-- 
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