0
votes

I am new to nHibernate. I understand how to use mapping using Fluent nHibernate. Now I would like to use a little more complex query. However I am not sure how I would map or even approach this. Here is what I would like to do in an sql query:

SELET 
  Zone,
  CountOfStyles = (Select Count(1) from anotherTable Where StoreZoneId = zone.ZoneID),
  ZoneId,
  ZoneTitle,
  ZoneDescription
FROM
  Zones

How would I map this using fluent nHibernate?

1

1 Answers

2
votes

I think this might get you started...

UPDATE:

mapping

Map(x => x.CountOfStyles).Formula("(Select Count(1) from anotherTable Where StoreZoneId = ZoneID)");