SOLVED:

The issue was that I was including the 'column' tag (.Column in FNH)
which must instruct NH to ignore any provided formula.



On Feb 3, 11:18 am, taber loveless <[email protected]> wrote:
> I have an issue where the case in a formula (generated by fluent)
> arent being used in the actual calls, any suggestions?
>
> DB CALL ISSUED (Missing CASE statement provided in formula):
> select vehicleeve0_.StateId   as StateId11_,
>        vehicleeve0_.latitude  as latitude11_,
>        vehicleeve0_.longitude as longitude11_,
>        vehicleeve0_.userId    as userId11_,
>        vehicleeve0_.time      as time11_,
>        vehicleeve0_.state     as state11_,
>        vehicleeve0_.statename as statename11_,
>        vehicleeve0_.transport as transport11_,
>        vehicleeve0_.TruckPCID as TruckPCID11_
> from   dbo.DTECH_Status vehicleeve0_
> where  (vehicleeve0_.TruckPCID in (209 /* @p2 */,367 /* @p3 */))
>        and (vehicleeve0_.state in ('TERRESTRIAL_LOCATION' /* @p4
> */,'SATELLITE_LOCATION' /* @p5 */,'PING_LOCATION' /* @p6
> */,'MSG_LOCATION' /* @p7 */))
>        and vehicleeve0_.time >= '2011-01-12T00:00:00.00' /* @p0 */
>        and vehicleeve0_.time <= '2011-01-30T00:00:00.00' /* @p1 */
>
> HBM (removed mscorlib etc before posting):
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> access="property" auto-import="true" default-cascade="none" default-
> lazy="true">
>   <class xmlns="urn:nhibernate-mapping-2.2" mutable="false"
> name="DriverTech.NH.Entities.VehicleEvent, DriverTech.NH"
> table="DTECH_Status">
>     <id name="EventId" type="System.Int32">
>       <column name="StateId" />
>       <generator class="identity" />
>     </id>
>     <component name="Coordinates" insert="true" update="true"
> optimistic-lock="true" class="DriverTech.NH.Entities.Coordinate,
> DriverTech.NH">
>       <property name="Latitude" type="System.Single">
>         <column name="latitude" not-null="false" />
>       </property>
>       <property name="Longitude" type="System.Single">
>         <column name="longitude" not-null="false" />
>       </property>
>     </component>
>     <property name="UserId" type="System.Int32">
>       <column name="userId" not-null="false" />
>     </property>
>     <property name="OccurredOn" type="System.DateTime">
>       <column name="time" />
>     </property>
>     <property name="EventType" type="Int32">
>       <column name="state" />
>     </property>
>     <property name="EventDetail" type="System.String">
>       <column name="statename" />
>     </property>
>     <property name="Transport" formula="(case when Transport =
> 'ORBCOMM' then 'Satellite' when Transport = 'TCP' then 'Cellular' when
> Transport = 'WIFI' then 'WiFi' end)"
> type="FluentNHibernate.Mapping.GenericEnumMapper`1[[DriverTech.Domain.TransmissionMode,
> DriverTech.Domain]], FluentNHibernate">
>       <column name="transport" />
>     </property>
>     <many-to-one class="DriverTech.NH.Entities.MapVehicleDetail,
> DriverTech.NH" name="VehicleDetail">
>       <column name="TruckPCID" />
>     </many-to-one>
>   </class>
> </hibernate-mapping>
>
> FLUENT MAPPING:
>     public class VehicleEventMap : ClassMap<VehicleEvent>
>     {
>         public VehicleEventMap()
>         {
>             Table("DTECH_Status");
>                 ReadOnly();
>             Id(x => x.EventId)
>                                 .Column(VehicleEvent.Columns.Id);
>                         References(x=>x.VehicleDetail)
>                                 .Column(VehicleEvent.Columns.TruckPCID);
>                 Map(x => x.UserId)
>                         .Column(VehicleEvent.Columns.UserId)
>                         .Nullable();
>                         Component(x => x.Coordinates, m =>
>                                                                               
>           {
>                                                                               
>                   m.Map(x => x.Latitude)
>                                                                               
>                           .Column(VehicleEvent.Columns.Latitude)
>                                                                               
>                           .Nullable();
>                                                                               
>                   m.Map(x => x.Longitude)
>                                                                               
>                           .Column(VehicleEvent.Columns.Longitude)
>                                                                               
>                           .Nullable();
>                                                                               
>           });
>                         Map(x => x.OccurredOn)
>                                 .Column(VehicleEvent.Columns.OccurredOn);
>             Map(x => x.EventType)
>                                 .Column(VehicleEvent.Columns.EventType)
>                                 .CustomType(typeof(int));
>             Map(x => x.EventDetail)
>                                 .Column(VehicleEvent.Columns.EventTypeName);
>                         Map(x => x.Transport)
>                                 .Column(VehicleEvent.Columns.TransmissionMode)
>                                 //.CustomType(typeof(TransmissionMode))
>                                 .Formula("(case when Transport = 'ORBCOMM' 
> then 'Satellite' when
> Transport = 'TCP' then 'Cellular' when Transport = 'WIFI' then 'WiFi'
> end)");
>         }

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