views:

47

answers:

1

hi,

I have the following named Queryé, whose result I like to get mapped on a class.

<sql-query name="GetIndustryCodes">
    <return class="IndustryCode">
      <return-property name="Sector_kategorie" column="Sector_kategorie"/>
      <return-property name="Sector_scheme_reference" column="Sector_scheme_reference"/>
      <return-property name="Group_Beschreibung" column="Group_Beschreibung"/>    
    </return>         
    <![CDATA[
       select * from 
  (
      select  
    lvl1.sprach_iso_cd,
      lvl1.kategorie Sector_kategorie,
      lvl1.scheme_reference Sector_scheme_reference,
      lvl1.Beschreibung Sector_Beschreibung, 

      lvl2.kategorie Group_kategorie,
      lvl2.scheme_reference Group_scheme_reference,
      lvl2.Beschreibung Group_Beschreibung, 

      lvl3.kategorie Industry_kategorie,
      lvl3.scheme_reference Industry_scheme_reference,
      lvl3.Beschreibung Industry_Beschreibung, 

      lvl4.kategorie Subindustry_kategorie ,
      lvl4.scheme_reference Subindustry_scheme_reference,
      lvl4.Beschreibung Subindustry_Beschreibung

      from StagingDb.Rds.GR3_S_R10916_TX  lvl1 

      left join  StagingDb.Rds.GR3_S_R10916_TX lvl2
      on  lvl2.sprach_iso_cd = lvl1.sprach_iso_cd 
      and lvl2.kategorie = 'MSCIS&PGroup'
      and lvl1.scheme_reference = substring(lvl2.scheme_reference,1,2)

      left join  StagingDb.Rds.GR3_S_R10916_TX lvl3
      on lvl3.sprach_iso_cd = lvl1.sprach_iso_cd 
      and lvl3.kategorie = 'MSCIS&PIndustry'
      and lvl2.scheme_reference = substring(lvl3.scheme_reference,1,4)

      left join  StagingDb.Rds.GR3_S_R10916_TX lvl4
      on lvl4.sprach_iso_cd = lvl1.sprach_iso_cd 
      and lvl4.kategorie = 'MSCIS&P'
      and lvl3.scheme_reference = substring(lvl4.scheme_reference,1,6)

      where lvl1.kategorie = 'MSCIS&PSector'

  ) t
  where t.sprach_iso_cd ='en'
    ]]>
  </sql-query>

Also I have a C# class

public class IndustryCode
    {
        public virtual string Sector_kategorie { get; set; }
        public virtual string Sector_scheme_reference { get; set; }
        public virtual string Sector_Beschreibung { get; set; }
        public virtual string Group_kategorie { get; set; }
        public virtual string Group_scheme_reference { get; set; }
        public virtual string Group_Beschreibung { get; set; }
        public virtual string Industry_kategorie { get; set; }
        public virtual string Industry_scheme_reference { get; set; }
        public virtual string Industry_Beschreibung { get; set; }
        public virtual string Subindustry_kategorie { get; set; }
        public virtual string Subindustry_scheme_reference { get; set; }
        public virtual string Subindustry_Beschreibung { get; set; }         

    }

Now whilst starting the program I get the exceptioné An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

InnerExceptioné"The given key was not present in the dictionary."

If I use the Query without the return class, then it works well except that I get the return value not mapped into a class. But the Class is definitely in the assembly. How can I map the query into a class?

Thank You very much

A: 

After some hacking I am convinced that I can only map the output of some SP to an Class which has a mapping to the DB.

So just having a sp and map it to some class will not work. the class must have an Mapping, therefore the class must a class of the domain model.

urpcor