0
votes

I've got the following database tables

 Messages
  - ID
  - Name
  - Date
  - CategoryID

 Categories
   - ID
   - Name

I've made a Fluent Nhibernate mapping which references Categories in the Messages map;

  public MessageMap()
    {
        Table("messages");
        Id(x => x.Id, "ID");
        Map(x => x.Name, "name");
        Map(x => x.Date, "date");
        References(x => x.Category).Column("categoryid");

    }

Now I want to make a selection of all Messages with a certain category name. I know I can do this looking up the category by name and then take the ID to select all messages. Still those 2 separate look ups can be combined in one, the fact is in Fluent NHibernate I don't know how.

1

1 Answers

1
votes

This has nothing to do with Fluent NHibernate. Using LINQ, you can do this:

session.Query<Message>().Where(x => x.Category.Name == "<your name>");