Domanda

Vorrei mappare il seguente sql in NHibernate. Per fare questo dovrò creare un oggetto entità separato, ad esempio RoomTypeVO mappato su tb_tags? Qualsiasi aiuto molto apprezzato.

SELEZIONARE   dbo.tb_rooms.id,   dbo.tb_rooms.name,   dbo.tb_tags.name AS 'roomType' A PARTIRE DAL   dbo.tb_rooms   INNER JOIN dbo.tb_tags ON (dbo.tb_rooms.typeID = dbo.tb_tags.id)

<id name="id" column="id">

  <generator class="native" />

</id>

<property name="name" />
È stato utile?

Soluzione

Se non è necessario eseguire una query sql diretta. Se vuoi usare HQL dovrai lavorare con un'entità.

Ma puoi sempre fare query sql direttamente.

Se hai un'entità mappata, probabilmente potresti semplicemente fare qualcosa del genere:

FROM RoomType 

Altri suggerimenti

Quando ti riferisci a 'DA', stai pensando a qualcosa del genere?

<property name="totalPrice"
formula="( SELECT SUM (li.quantity*p.price) FROM LineItem li, Product p
            WHERE li.productId = p.productId
            AND li.customerId = customerId
            AND li.orderNumber = orderNumber )"/>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top