ive asked a similar question but i am still in doubt about what to do so i wanted to ask this question with abit more information:
Say for instance i have the following Object:
public class Callback : SuperObject
{
public virtual DateTime PERIOD { get; set; }
public virtual int COMPLETED { get; set; }
public virtual int COMPLETED_WITHIN_2HOURS { get; set; }
}
Now the if i add an XML file containing the mapping information:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Henvendelser" namespace="Henvendelser.Objects.Callback">
<class name="Henvendelser.Objects.Callback">
<id name="PERIOD" column="PERIOD">
<generator class="identity" />
</id>
<property name="COMPLETED" />
<property name="COMPLETED_WITHIN_2HOURS" />
</class>
</hibernate-mapping>
Then the following will run perfectly fine:
var query = new StringBuilder();
query.Append("SELECT LAST_UPD AS PERIOD, ");
query.Append("COUNT(CASE WHEN STATUS ='Færdig' THEN 1 END) as completed, ");
query.Append("COUNT(CASE WHEN SOLVED_SECONDS /60 /60 <= 2 THEN 1 END) as completed_within_2hours ");
query.Append("FROM KS_DRIFT.NYK_SIEBEL_CALLBACK_AGENT_H_V ");
query.Append("WHERE LAST_UPD BETWEEN '" + start.ToString("yyyy-MM-dd") + "' AND '" + end.ToString("yyyy-MM-dd") + "' ");
query.Append("AND STATUS ='Færdig' ");
query.Append("GROUP BY LAST_UPD ORDER BY LAST_UPD ASC");
var session = sessionFactory.OpenSession();
var result = session.CreateSQLQuery(query.ToString()).AddEntity(typeof(Callback)).List<Callback>();
Which is great however in a larger program i might have 10 or more different objects which means that in this case i would have to make 10 xml files that maps the object. Now in my logic the mapping xml is basicly saying how the object class already looks like so it seems kinda redundant!
is there a better way?