If you want to retrieve some value from a database you always has to use a class that shall contain a lot of data.
In my case, I want to retrieve one value only from a stored procedure and do I really need to use a class that shall contain a single value only?
How should I create inside of the .hbm.xml and how should I write in c# code when I don't want to use a class?
The code below is used when you need to have class that shall contain a lot of data.
 
 
 Keyword: Nhibernate, XML, Csharp
sp_retrieveAllProductList.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="data_layer" namespace="data_layer">
  <sql-query name="sp_retrieveAllProductList">
    <return-scalar column="Produkt" type="string" />
    <return-scalar column="Produkt_kategori" type="string" />
    <return-scalar column="btn_namn" type="string" />
    exec sp_retrieveAllProductList :Produkt_kategori
  </sql-query>
</hibernate-mapping>
        public IList<Product4> RetrieveAllProductWithPriceNameAndBtn()
        {
            return _session.GetNamedQuery("sp_retrieveAllProductList2")
                            .SetResultTransformer(Transformers.AliasToBean(typeof(Product4)))
                            .List<Product4>();     
        }
        
        
        
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace data_layer
{
    public class Product4
    {
        public virtual string PK_produkt { get; set; }
        public virtual string Produkt { get; set; }
        public virtual string Produkt_kostnad { get; set; }
        public virtual string btn_namn { get; set; }
    }
}